<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
 <channel>
  <atom:link href="http://www.comsol.de/community/forums/matlab/rss/feed.rss" rel="self" type="application/rss+xml"/>
  <title>MATLAB - Latest Discussions - COMSOL Forums</title>
  <link>http://www.comsol.de/community/forums/</link>
  <description>Most recent forum discussions</description>
  <pubDate>Mon, 02 Apr 2012 17:55:35 +0000</pubDate>
  <image>
   <title>MATLAB - Latest Discussions - COMSOL Forums</title>
   <url>http://www.comsol.de/shared/images/logos/comsol_logo.gif</url>
   <link>http://www.comsol.de/community/forums/</link>
  </image>
  <item>
   <title>Solving same model in COMSOL and Matlab yields different results</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/27487/</link>
   <description>Background:&lt;br /&gt;&#13;
I have a model created in COMSOL with mostly ellipsoids containing cylinders inside (different material), then joined with each other. Originally it gave me a hard time in meshing because I did not know how to &amp;quot;smooth out&amp;quot; the contact edges where the meshing gets extremely fine, so that it either threw meshing problem or divergent linear solution problem. With trial-and-error for a long time in every possible way, I simplified the model and perhaps marginally resolved the issue. At least, when I directly compute from COMSOL, it never complains.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Problem:&lt;br /&gt;&#13;
However, as I scripted it into Matlab because I needed to run different cases (where surface potential at some terminal differs), I got &amp;quot;divergence in linear solution,&amp;quot; which threw me something like &amp;quot;java util exception.&amp;quot;&lt;br /&gt;&#13;
What I did was simply save the working, solvable model as m-file, and called it from Matlab console, exactly same thing! But Matlab would not cooperate. And this error occurs only at some of the cases that I tried to run. e.g., case 1~4 passed, case 5, takes much longer than usual, then boom - error messages in red. &lt;br /&gt;&#13;
And also, even for the cases that did run, the solution was different from what was obtained by directly running from COMSOL. By &amp;quot;different,&amp;quot; I mean off by more than 20% in some cases, which is way beyond the error margin that I am used to when running COMSOL.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Help:&lt;br /&gt;&#13;
Did anyone have similar experience? Different solution when running from COMSOL, than running through Matlab?&lt;br /&gt;&#13;
What differences may occur even though I simply save the COMSOL model as m-file?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Thank you.</description>
   <pubDate>Mon, 02 Apr 2012 17:55:35 +0000</pubDate>
   <guid isPermaLink="false">.1333389335.27487</guid>
  </item>
  <item>
   <title>Finding face numbers after revolution</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/26900/</link>
   <description>If I define a series of curves, and then make them solid, and revolve them, how do I go about figuring out which faces correspond to which curves?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
For example, if I have cur1 through cur6 defined previously, and I use:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
carr = {cur1,cur2,cur3,cur4,cur5,cur6};&lt;br /&gt;&#13;
g1 = geomcoerce('solid',carr);&lt;br /&gt;&#13;
g2 = revolve(g2,'revaxis',[0 1;0 0],'wrkpln',[0 0 1;0 0 0;0 1 0]);&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
How do I determine which face numbers of g2 correspond to cur4?&lt;br /&gt;&#13;
I know I can change the second line to&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
[g1 ctx] = geomcoerce('solid',carr,'out','ctx');&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
To get which curves in the solid object correspond to each of the initial curves, and use:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
[c4,~] = find(ctx{4});&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
to extract this information regarding curve 4.  But I don't know how to take this information and get the face number out.  Any help woulud be greatly appreciated.</description>
   <pubDate>Mon, 12 Mar 2012 22:07:27 +0000</pubDate>
   <guid isPermaLink="false">.1331590047.26900</guid>
  </item>
  <item>
   <title>Comsol 4.1 with Matlab 2011b</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/26799/</link>
   <description>Dear All,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I am trying to connect Matlab 2011b to the Comsol Server I started locally.&lt;br /&gt;&#13;
However, when I type 'mphstart' in matlab I get the following error:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Error using mphstart (line 71)&lt;br /&gt;&#13;
A connection to Comsol could not be established.&lt;br /&gt;&#13;
Please check that a Comsol Server is started prior&lt;br /&gt;&#13;
to calling mphstart&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Even though the comsol server is running and the comsol client has no problem connecting&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Can anyone help?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Regards,&lt;br /&gt;&#13;
Colin Simons</description>
   <pubDate>Fri, 09 Mar 2012 09:49:53 +0000</pubDate>
   <guid isPermaLink="false">.1331286593.26799</guid>
  </item>
  <item>
   <title>How to keep Matlab function going on after non-convergence?</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/24848/</link>
   <description>I'm using Matlab to run a series of automated simulations. Each simulation has a slightly different geometry (there is no topological change). Some of these simulations don't converge, which is fine. The problem is that when one of them don't converge the function stops and all following simulations are not executed.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I want the Matlab function to continue, even if one of the simulations stops. For example: let's say I have the simulations A, B, C and D to run. I create a Matlab function that runs all of them, one at a time in the alphabetical order. But if B doesn't converge the function stops, C and D are not calculated. I want it to just save B as it is (with the error) and go on to simulate C and D.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Does someone know how to avoid the Matlab function to stop when the model doesn't reach convergence?</description>
   <pubDate>Thu, 15 Dec 2011 11:49:32 +0000</pubDate>
   <guid isPermaLink="false">.1323949772.24848</guid>
  </item>
  <item>
   <title>External matlab function -matlab Path and ElemStruct problems</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/24455/</link>
   <description>Hi everyone,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I’m building an external matlab function and following the guidance of the document. But the function fails to work. The matlab function is same as what the document ‘LiveLink For MATLAB Users' Guide’ (page 42) says:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
function c=func1(x)&lt;br /&gt;&#13;
c=(x./1.6).*(x&amp;gt;0.6)+(x.^2+0.3).*(x&amp;lt;=0.6);&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
The .m file is save as ‘func1.m’ as the attachment shown. Then in COMSOL, I build/add a matlab node under the Global Definitions (Global Definitions – Functions –Matlab), then specify the function/argument, and finally the plot parameters. But, when I use “plot” to plot the function, it doesn’t work.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
 &lt;br /&gt;&#13;
Fig. 1 Operating flow&lt;br /&gt;&#13;
(all the pictures and text are illustrated in the .doc file, thanks. )&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Question one:&lt;br /&gt;&#13;
About the matlab and COMSOL path relative to the external matlab function&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
The matlab path:&lt;br /&gt;&#13;
 &lt;br /&gt;&#13;
Fig. 2 the path of matlab&lt;br /&gt;&#13;
(Ps. I didn’t set the path to “E:\papers\paper COMSOL”)&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
1.  When I put the .m and .mph files to the “D:\COMSOL 4.2a\COMSOL42a”, then the error “failure loading matlab libraries, this model requires that matlab is available” appears.&lt;br /&gt;&#13;
 &lt;br /&gt;&#13;
Fig. 3 the loading error&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
2.  When I put both files under the directory “E:\papers\paper COMSOL”&lt;br /&gt;&#13;
 &lt;br /&gt;&#13;
Fig. 4 the save path of both files&lt;br /&gt;&#13;
The error mentioned above disappears, while another error “internal error: cannot convert ElemStruct to int” comes,&lt;br /&gt;&#13;
 &lt;br /&gt;&#13;
Fig. 5 the ElemStruct error&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
The above phenomena puzzle me a lot, the matlab path can be change very easily and take effect immediately. Does during these change in matlab path, the COMSOL don’t responses correspondingly?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Question two: &lt;br /&gt;&#13;
How to solve the “internal error: cannot convert ElemStruct to int” problem&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I have searched the forum and find Annika Rödder have encountered the same problem (see website http://www.comsol.com/community/forums/general/thread/23188/ for details). However, I haven’t understood the answer and underlying problem.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Could you give me some guidance?&lt;br /&gt;&#13;
Thanks for your response sincerely. Best wishes to you and your family.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
FM Huang&lt;br /&gt;&#13;
Dec. 1st. 2011&lt;br /&gt;&#13;
</description>
   <pubDate>Thu, 01 Dec 2011 07:04:37 +0000</pubDate>
   <guid isPermaLink="false">.1322723077.24455</guid>
  </item>
  <item>
   <title>Basic Comsol-Matlab Problem</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/23927/</link>
   <description>Hi,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I am new to using comsol with matlab so i apologise if this is an obvious question.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
As a first step I am simply trying to save a model as a .m file and then run it in matlab. When i try to do this is get the following error message in matlab:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Undefined variable &amp;quot;ModelUtil&amp;quot; or class&lt;br /&gt;&#13;
&amp;quot;ModelUtil.create&amp;quot;.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Error in play1 (line 10)&lt;br /&gt;&#13;
model = ModelUtil.create('Model');&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I am running comsol 4.2.0.228 on a mac, and matlab R2011b (7.13.0.564) both 64bit.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
The model is an extremely simple one, just a 2D bimetallic cantilever with a fixed constraint at one end being subjected to a temperature. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Does anyone know what this error message means, and if its a common problem how i can fix it?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Are there any tutorials on using the Matlab LiveLink, comsol seem to provide them for most other modules but i couldn't see any?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Any help is much appreciated.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Joe</description>
   <pubDate>Mon, 14 Nov 2011 13:26:15 +0000</pubDate>
   <guid isPermaLink="false">.1321277175.23927</guid>
  </item>
  <item>
   <title>Can't execute mphgeom or mphmesh in Matlab</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/23553/</link>
   <description>&lt;br /&gt;&#13;
I'm working through the example on pp. 26-28 of the LiveLink for Matlab User's guide.  The simulation runs just fine, and the results can be plotted using mphplot.  However, I get these Matlab errors when I try to view the geometry or mesh using mphgeom or mphmesh:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
For mphgeom:&lt;br /&gt;&#13;
***&lt;br /&gt;&#13;
Subscript indices must either be real positive integers or logicals.&lt;br /&gt;&#13;
Error in ==&amp;gt; C:\COMSOL42\mli\mphpatch.p&amp;gt;mphpatch at 144&lt;br /&gt;&#13;
Error in ==&amp;gt; C:\COMSOL42\mli\mphgeom.p&amp;gt;mphgeom at 75&lt;br /&gt;&#13;
***&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
For mphmesh:&lt;br /&gt;&#13;
***&lt;br /&gt;&#13;
Subscript indices must either be real positive integers or logicals.&lt;br /&gt;&#13;
Error in ==&amp;gt; C:\COMSOL42\mli\mphmesh.p&amp;gt;mphmesh at 122&lt;br /&gt;&#13;
***&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I'm quite proficient with Matlab, but as these are p-files, I can't see where the problem lies.  I'm running Matlab 2008a.  Will these errors disappear if I upgrade?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Cheers,&lt;br /&gt;&#13;
Brian</description>
   <pubDate>Tue, 01 Nov 2011 15:11:38 +0000</pubDate>
   <guid isPermaLink="false">.1320160298.23553</guid>
  </item>
  <item>
   <title>exporting matlab functions in comsol3.5a</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/22893/</link>
   <description>Hello all,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I want to use function defined in matlab file by providing input variable through comsol 3.5a and I want to use output value of matlab program in my simulation. like subroutine but with simple equations.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
can someone tell me how to define it in comsol 3.5a&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
thanks</description>
   <pubDate>Wed, 05 Oct 2011 13:10:52 +0000</pubDate>
   <guid isPermaLink="false">.1317820252.22893</guid>
  </item>
  <item>
   <title>How to prevent the generation of mphm file during the connection with matlab</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/22691/</link>
   <description>I used comsol 3.5a to build my model, and connection to matlab. Every step is fellowed from reset model to remesh and save to .m file. But when the .m file was saved, the geometry file flbinary file .mphm generated. I don't want this file, because the script was supposed to change in matlab to change the geometry parameter in the model. And in this condition the matlab script just reference the flbinary directly without any parameter of geometry in script. How to prevent the process? I tried to build everything from beginning, and comsol could remember the geometry para, however, even I save it to another file, the flbinary file generated. How could I do?</description>
   <pubDate>Mon, 26 Sep 2011 12:16:41 +0000</pubDate>
   <guid isPermaLink="false">.1317039401.22691</guid>
  </item>
  <item>
   <title>a livelink problem for point probe coordinate</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/22048/</link>
   <description>                I'm testing the livelink version of my COMSOL code as attached. In general, I set two point probes at different locations (e.g. each end of a line). The COMSOL code is runing regardless whether the result is meaningful. But the .m file stops with error.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
                Somehow there is a bug regarding the following probe definition lines in .m file:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
model.result.table('tbl1').name('Probe Table 1');&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
model.probe('pdom1').set('bndsnap1', true);&lt;br /&gt;&#13;
model.probe('pdom1').feature('ppb1').set('table', 'tbl1');&lt;br /&gt;&#13;
model.probe('pdom1').feature('ppb1').set('window', 'window1');&lt;br /&gt;&#13;
model.probe('pdom2').set('coords1', {'1'});&lt;br /&gt;&#13;
model.probe('pdom2').feature('ppb2').set('table', 'tbl1');&lt;br /&gt;&#13;
model.probe('pdom2').feature('ppb2').set('window', 'window1');&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
                 The Matlab error information as follow (unrecognized coordinate or units):&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
??? Java exception occurred:&lt;br /&gt;&#13;
Exception:&lt;br /&gt;&#13;
	com.comsol.nativeutil.properties.InvalidPropertyValueException:&lt;br /&gt;&#13;
    Invalid property value&lt;br /&gt;&#13;
Messages:&lt;br /&gt;&#13;
	Invalid property value&lt;br /&gt;&#13;
	- Property: coords1&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
	X is Y#Coordinates#a matrix of real numbers&lt;br /&gt;&#13;
	- : Expected size is 1Ã—1&lt;br /&gt;&#13;
	- : Expected unit is: m.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
                 Anyone has a hint of the correct livelink setting regarding the probe?&lt;br /&gt;&#13;
</description>
   <pubDate>Tue, 30 Aug 2011 11:41:48 +0000</pubDate>
   <guid isPermaLink="false">.1314704508.22048</guid>
  </item>
  <item>
   <title>Problem with create new solution in comsol 4.1</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/16898/</link>
   <description>Hi&lt;br /&gt;&#13;
I have problem with crating a solution using script in Comsol 4.1. In help I read that Comsol enabled functionality to  manipulate solutions (see help model.sol). I want to creates a solution object from more than one solutions.  The Comsol provides function  model.sol(&amp;lt;tag&amp;gt;).createSolution().  In accordingly with the Comosol Manual a new created solutions is based on the input from the following sets (real and imaginary components)  setU(int,double[]),setPNames(String[]),setPVals(double[]),setPVals(int,double[]) The solution is created at this stage. Afterwards the user input is cleared. If a created solution is used before this function is run the result is unpredictable. When I call createSolution function we get following exception:&lt;br /&gt;&#13;
??? Java exception occurred:&lt;br /&gt;&#13;
Exception:&lt;br /&gt;&#13;
	java.lang.NullPointerException&lt;br /&gt;&#13;
	(rethrown as com.comsol.util.exceptions.FlException)&lt;br /&gt;&#13;
Messages:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Stack trace:&lt;br /&gt;&#13;
	at com.comsol.model.impl.SolverSequenceImpl.K(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.model.impl.SolverSequenceImpl.createSolution(Unknown Source)&lt;br /&gt;&#13;
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt;&#13;
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;&#13;
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)&lt;br /&gt;&#13;
	at java.lang.reflect.Method.invoke(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.clientserver.impl.JobImpl.run(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.server.internal.b.a(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.server.internal.b.a(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.server.internal.b$h.a(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.server.internal.b$h.a(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.server.internal.b$h$a.run(Unknown Source)&lt;br /&gt;&#13;
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)&lt;br /&gt;&#13;
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)&lt;br /&gt;&#13;
	at java.lang.Thread.run(Unknown Source)&lt;br /&gt;&#13;
Error in ==&amp;gt; przyklad at 147&lt;br /&gt;&#13;
model.sol('sol3').createSolution()&lt;br /&gt;&#13;
model.study.create('std3');&lt;br /&gt;&#13;
model.study('std3').feature.create('time', 'Transient');&lt;br /&gt;&#13;
model.study('std3').feature('time').set('tlist', {'0','0.1','0.2'});&lt;br /&gt;&#13;
model.sol.create('sol3');&lt;br /&gt;&#13;
model.sol('sol3').study('std3');&lt;br /&gt;&#13;
model.sol('sol3').feature.create('st1', 'StudyStep');&lt;br /&gt;&#13;
model.sol('sol3').feature('st1').set('study', 'std3');&lt;br /&gt;&#13;
model.sol('sol3').feature('st1').set('studystep', 'time');&lt;br /&gt;&#13;
model.sol('sol3').feature.create('v1', 'Variables');&lt;br /&gt;&#13;
model.sol('sol3').feature.create('t1', 'Time');&lt;br /&gt;&#13;
model.sol('sol3').feature('t1').set('tlist', {'0','0.1','0.2'});&lt;br /&gt;&#13;
 &lt;br /&gt;&#13;
%Create new solution&lt;br /&gt;&#13;
model.sol('sol3').setPNames(model.sol('sol2').getPNames());&lt;br /&gt;&#13;
model.sol('sol3').setPVals([0.0045,0.005,0.0055]);&lt;br /&gt;&#13;
model.sol('sol3').setPValsImag([0.0045,0.005,0.0055]);&lt;br /&gt;&#13;
model.sol('sol3').setU(1,model.sol('sol1').getU(1));&lt;br /&gt;&#13;
model.sol('sol3').setUImag(1,model.sol('sol1').getUImag(1));&lt;br /&gt;&#13;
model.sol('sol3').setU(2,model.sol('sol2').getU(2));&lt;br /&gt;&#13;
model.sol('sol3').setUImag(2,model.sol('sol2').getUImag(2));&lt;br /&gt;&#13;
model.sol('sol3').setU(3,model.sol('sol2').getU(3));&lt;br /&gt;&#13;
model.sol('sol3').setUImag(3,model.sol('sol2').getUImag(3));&lt;br /&gt;&#13;
model.sol('sol3').createSolution();&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
The  sol1 and sol2 consist  a results of calculation.&lt;br /&gt;&#13;
Can you help me!!! What should I do to create a new solution properly without any exception using script Comsol  4.1??&lt;br /&gt;&#13;
</description>
   <pubDate>Wed, 13 Apr 2011 14:43:17 +0000</pubDate>
   <guid isPermaLink="false">.1302705797.16898</guid>
  </item>
  <item>
   <title>Mass and stifness matrix</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/15908/</link>
   <description>I am modeling a piezoelectric structure in an eigenfreq analysis.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
i export my model in matlab as fem and as state space model&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Mass matrix is zero, why? (i use assemble command)&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
M matrix in state space model is zero, why?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Any help woulb be great, thanks in advance&lt;br /&gt;&#13;
</description>
   <pubDate>Thu, 24 Mar 2011 09:09:09 +0000</pubDate>
   <guid isPermaLink="false">.1300957749.15908</guid>
  </item>
  <item>
   <title>How to store parametric sweep results in single file or MATLAB variable</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/12530/</link>
   <description>Hello &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I need to perform several nested parametric sweeps in order to vary several geometric parameters simultaneously (I'm using Comsol version 4.0a) &lt;br /&gt;&#13;
If I add a &amp;quot;Report to file&amp;quot; task in the inner parametric sweep, in order to export the value, say, of a line integration along one boundary, COMSOL generates one text file per parameters set. &lt;br /&gt;&#13;
This is very unconfortable in my case in which I have several thousand of parameter sets. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Do anyone know a way to export the calculated quantities in a single text file? &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I cannot store the solution for every parameter set in the model and perform the calculation of the derived quantities after solving,  since the whole mph file would be become too large.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I tried to work with the .m file and Comsol + matlab livelink but I still couldn't get rid of this problem.  The code automatically generated by Comsol contains the following lines&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
model.batch.create('p1', 'Parametric');&lt;br /&gt;&#13;
model.batch('p1').feature.create('so1', 'Solutionseq');&lt;br /&gt;&#13;
model.batch('p1').feature.create('nu1', 'Numericalseq');&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
but I can't understand how to access the calculated quantities in the numerical sequence.&lt;br /&gt;&#13;
  &lt;br /&gt;&#13;
Thanks for reading &lt;br /&gt;&#13;
best regards, &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Pierfrancesco </description>
   <pubDate>Mon, 03 Jan 2011 18:32:05 +0000</pubDate>
   <guid isPermaLink="false">.1294079525.12530</guid>
  </item>
  <item>
   <title>LiveLink &quot;selection.set&quot;</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/10259/</link>
   <description>Hello All,&lt;br /&gt;&#13;
I'm having what I believe to be a pretty straightforward problem getting the selection.set function to work properly. I am learning LiveLink by building up a model step by step, exporting to an m file at every step and keeping the parts of the script I need. For some reason, playing back any commands which require me to set a selection do not work (even if I did not modify them at all after export). For example:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
model.physics('es').selection.set([1]);&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Here is the error I get in matlab (where the illegal input vector is, I believe, the key part):&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
??? Java exception occurred:&lt;br /&gt;&#13;
Exception:&lt;br /&gt;&#13;
	java.lang.IllegalArgumentException: Illegal input vector&lt;br /&gt;&#13;
	(rethrown as com.comsol.util.exceptions.FlException)&lt;br /&gt;&#13;
Messages:&lt;br /&gt;&#13;
	Illegal input vector&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Stack trace:&lt;br /&gt;&#13;
	at com.comsol.model.impl.SelectionImpl.a(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.model.impl.SelectionImpl$b.a(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.model.impl.SelectionImpl$b.execute(Unknown Source)&lt;br /&gt;&#13;
	at com.comsol.model.clientserver.ClientManagerImpl$d.call(Unknown Source)&lt;br /&gt;&#13;
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)&lt;br /&gt;&#13;
	at java.util.concurrent.FutureTask.run(Unknown Source)&lt;br /&gt;&#13;
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)&lt;br /&gt;&#13;
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)&lt;br /&gt;&#13;
	at java.lang.Thread.run(Unknown Source)&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Error in ==&amp;gt; scratch_10142010 at 111&lt;br /&gt;&#13;
model.physics('es').selection.set([1 2 3]);&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
As a side note, how does Comsol number the domains that are created from the various geometry operations? If I were writing this code 'blind' how would I know how to select domains, boundaries, etc.. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Thanks, Mike</description>
   <pubDate>Thu, 14 Oct 2010 23:36:03 +0000</pubDate>
   <guid isPermaLink="false">.1287099363.10259</guid>
  </item>
  <item>
   <title>Tip: Batch calculations with Matlab + Comsol 4.0a </title>
   <link>http://www.comsol.de/community/forums/matlab/thread/9299/</link>
   <description>Hi,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I just wanted to share my experience regarding batch-type (i.e., non-interactive) calculations using comsol 4.0a and the matlab livelink. I lost quite some time trying to run a comsol matlab script (.m file) on a linux cluster, and I thought some people might be interested in hearing the workaround I found.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
When working with the cluster, I have two major constraints:&lt;br /&gt;&#13;
1. I do not have any kind of display (X) support,&lt;br /&gt;&#13;
2. I have to submit the calculation via  a simple bash script.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
In 3.5a, running a .m file in batch mode was very easy (At the very least, it was nicely documented : http://www.comsol.com/support/knowledgebase/980/), One would use: &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
comsol matlab -ml -nodesktop -ml -nosplash -mlr &amp;quot;myscript, exit&amp;quot;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
In comsol 4.0a, using something along the lines of&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
comsol server matlab -nodesktop -nosplash -r myfile &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
does not lead to similar behavior. First, an xterm is spawned, and the 'nodesktop' matlab runs in this new terminal. The '-r myfile' option is ignored, and matlab does not run my .m file on startup. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
To work around the fact that 'comsol server matlab' spawns an xterm, I was told by comsol support to do the following:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
1. Start the comsol server&lt;br /&gt;&#13;
2. Start matlab, and connect to the server using mphstart&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
To be able to do this within one bash script, I basically had to launch the server in the background. However, I could not use&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
comsol server &amp;amp;&lt;br /&gt;&#13;
matlab -nodesktop -nosplash -r myfile&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
as the server process would stop before matlab could connect to it whenever it was launched as a background process. By using instead&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
comsol server &amp;lt;/dev/null &amp;gt; /dev/null  &amp;amp;&lt;br /&gt;&#13;
matlab -nodesktop -nosplash -r myfile&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
instead of simply  &amp;quot;comsol server &amp;amp;&amp;quot; then the server process is not stopped and you can run matlab, connect to comsol server, and run your .m script, without any user-intervention nor need for X support. Also, the comsol server exits when running ModelUtil.disconnect in Matlab, so I don't leave any process on the compute node..&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Hoping this might be useful for someone ;)&lt;br /&gt;&#13;
By the way, if anyone has a better (cleaner?) way of achieving the same thing, I'd be happy to hear it!&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Charles&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
</description>
   <pubDate>Thu, 09 Sep 2010 11:26:48 +0000</pubDate>
   <guid isPermaLink="false">.1284031608.9299</guid>
  </item>
  <item>
   <title>Creating and using external Matlab functions</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/7946/</link>
   <description>Does anyone have any experience in creating and using &lt;br /&gt;&#13;
external Matlab functions?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I am running Comsol 4.0a, and would like to be able to pass &lt;br /&gt;&#13;
parameters to a Matlab function, do some calculations, pass &lt;br /&gt;&#13;
the results back to Comsol and assign them to a variable. It &lt;br /&gt;&#13;
would also be really useful to be able to pass back and assign &lt;br /&gt;&#13;
an array of results to Comsol variables. An example of this &lt;br /&gt;&#13;
would be in the Chemical Reaction Engineering Module &lt;br /&gt;&#13;
where one might want to compute externally an array of&lt;br /&gt;&#13;
reaction coefficients for assignment to Comsol. Is this&lt;br /&gt;&#13;
possible?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I have no problem launching Live Link and exporting models &lt;br /&gt;&#13;
to Matlab. However, the procedures for defining and invoking &lt;br /&gt;&#13;
a Matlab function from within Comsol are unclear in the &lt;br /&gt;&#13;
documentation.  The basic description is:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
1. Right click Global Definitions, and then go to Functions=&amp;gt;Matlab&lt;br /&gt;&#13;
A MATLAB1 node is created.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
2. Select the MATLAB1 node, and under Settings, enter in the required&lt;br /&gt;&#13;
information. This includes the Function name and Arguments. There&lt;br /&gt;&#13;
is a button for plotting the function, but it invokes an error message&lt;br /&gt;&#13;
saying you can't plot a Matlab function.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
3. Comsol can't fiind any external Matlab function that I create.&lt;br /&gt;&#13;
I tried numerous things, including putting the function in the&lt;br /&gt;&#13;
default Matlab 2010a path, in the Comsol 4.0a directory,&lt;br /&gt;&#13;
etc. None of them worked.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Things that are expected but missing from the Matlab&lt;br /&gt;&#13;
function interface and the documentation are:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
1. The path to a stored Matlab m-file with the function.&lt;br /&gt;&#13;
How does Comsol know where to look for it, or does&lt;br /&gt;&#13;
it follow the Matlab path tree as defined in Matlab? Is&lt;br /&gt;&#13;
it possible to define a path within Comsol independent&lt;br /&gt;&#13;
of Matlab (this would be preferable, since it wouldn't&lt;br /&gt;&#13;
require messing with an otherwise stable Matlab tree.)&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
2. Some information about restrictions on usage of such&lt;br /&gt;&#13;
a function, for example only allow return values of floating&lt;br /&gt;&#13;
point, and no arrays permitted. (see my comment above&lt;br /&gt;&#13;
about reaction rates.)&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
3. At least one worked example illustrating proper&lt;br /&gt;&#13;
usage would be very useful.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Anyone with experience successfully doing this?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Thanks!&lt;br /&gt;&#13;
Dave</description>
   <pubDate>Fri, 30 Jul 2010 16:00:42 +0000</pubDate>
   <guid isPermaLink="false">.1280505642.7946</guid>
  </item>
  <item>
   <title>Matlab script for effective modal mass extraction</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/2650/</link>
   <description>Hi everbody,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
as posted frequently in this forum, COMSOL does not provide effective modal masses in eigenfrequency analysis for structural analysis. But since effective masses are a very convenient way to determine critical modes from less critical ones, and since this information is often required for documentation, I wrote a Matlab script that extracts the effective masses from an eigenfrequency solution and exports them to an Excel file. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
This is how it works:&lt;br /&gt;&#13;
1. Copy the attached matlab script to your disk (preferably to a directory that is already in the Matlab include path, e.g. C:\Users\...\Documents\MATLAB on windows). &lt;br /&gt;&#13;
2. Run COMSOL and do the eigenfrequency analysis there.&lt;br /&gt;&#13;
3. Save your COMSOL eigenfrequency analysis to an .mph file of your choice. &lt;br /&gt;&#13;
4. Connect COMSOL to Matlab (you don't need to export the fem object to Matlab though).&lt;br /&gt;&#13;
5. In Matlab, execute the attached effective_mass_analysis.m script (open/run or if located in the Matlab workspace simply type 'effective_mass_analysis' in the command window).&lt;br /&gt;&#13;
6. The script asks you which .mph file to open, calculates the effective masses and saves them to a Microsoft Excel spreadsheet (you will be prompted where to save it). &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
In the Excel file there are four different sheets: 'Total Masses', 'Effective Masses', 'Mass Fraction' and 'Cumulative Mass Fraction'. These results resemble the standard output of other FEM software, such as Ansys that provide effective mass output by default. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Unfortunately, this script does not work for large models since the matrix size that Matlab can handle is limited and it may also fail when more than one application mode is used. I have cross-checked the results with only one reference case from Ansys, so there is no guarantee that the script works correctly with all models. Any comments and suggestions are greatly appreciated. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Cheers,&lt;br /&gt;&#13;
Lars</description>
   <pubDate>Fri, 15 Jan 2010 12:15:27 +0000</pubDate>
   <guid isPermaLink="false">.1263557727.2650</guid>
  </item>
  <item>
   <title>Exporting Comsol data to Matlab?</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/1715/</link>
   <description>Hello  everybody,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I want to postprocess Comsol data in Matlab. Since Ascii files blow up in size and I get &amp;quot;out of memory error&amp;quot;, I'm looking for some other way. I've no experience with Comsol-Matlab interface and it seems to me that this interface is not working in my system. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Could someone please tell me, how to export Postprocessing data in some Matlab-compatible format (not Ascii)?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I've converted a Comsol model (after executing) into an m-file and wanted to run it in Matlab (running separately from Comsol) but Matlab is probably not able to read the flbinaryfile (*.mphm). Any suggestion, what could be wrong here?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Thanks.&lt;br /&gt;&#13;
Daniel</description>
   <pubDate>Wed, 18 Nov 2009 11:00:06 +0000</pubDate>
   <guid isPermaLink="false">.1258542006.1715</guid>
  </item>
  <item>
   <title>Problem by running Comsol35a with Matlab2009a on Linux (Ubuntu 9.04) 64 bits</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/467/</link>
   <description>hi,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I just install Comsol(35a) in connection with Matlab(R2009a) on a 64-bits Linux machine (Ubuntu 9.04).&lt;br /&gt;&#13;
Actually I submit the Comsol jobs in a m.file with the following command in the Linux terminal:&lt;br /&gt;&#13;
/usr/local/comsol35a/bin/comsol matlab -ml -nodesktop -ml -nosplash -mlr job.m&lt;br /&gt;&#13;
But I get the following error message:&lt;br /&gt;&#13;
------------------------------------------------------------------------&lt;br /&gt;&#13;
                            &amp;lt; M A T L A B (R) &amp;gt;&lt;br /&gt;&#13;
                  Copyright 1984-2009 The MathWorks, Inc.&lt;br /&gt;&#13;
                Version 7.8.0.347 (R2009a) 64-bit (glnxa64)&lt;br /&gt;&#13;
                             February 12, 2009&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
  To get started, type one of these: helpwin, helpdesk, or demo.&lt;br /&gt;&#13;
  For product information, visit www.mathworks.com.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
 ** On entry to DGESVD parameter number 13 had an illegal value&lt;br /&gt;&#13;
------------------------------------------------------------------------&lt;br /&gt;&#13;
I try to install Comsol(35a) and Matlab(R2009a) on a 32-bit Linux machine. In this case this command perfectly works.&lt;br /&gt;&#13;
Does Anybody known what I am doing wrong with the 64-bit Linux machine?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Thanks a lot in advance for your help.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Magalie Huttin</description>
   <pubDate>Fri, 14 Aug 2009 10:58:23 +0000</pubDate>
   <guid isPermaLink="false">.1250247503.467</guid>
  </item>
  <item>
   <title>Import Matlab m-file back to COMSOL</title>
   <link>http://www.comsol.de/community/forums/matlab/thread/365/</link>
   <description>Hi,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I have a Matlab m-file that was generated by COMSOL previously. I made some changes since. Now I wonder if it is possible to import it back to COMSOL again. Thanks.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Wan</description>
   <pubDate>Tue, 04 Aug 2009 14:00:57 +0000</pubDate>
   <guid isPermaLink="false">.1249394457.365</guid>
  </item>
 </channel>
</rss>

