<?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.eu/community/forums/general/rss/thread/3392.rss" rel="self" type="application/rss+xml"/>
  <title>COMSOL Forums: Interpolation .txt-File Format Error: 9048</title>
  <link>http://www.comsol.eu/community/forums/general/thread/3392/</link>
  <description>Most recent forum messages</description>
  <pubDate>Wed, 10 Mar 2010 05:38:45 +0000</pubDate>
  <image>
   <title>COMSOL Forums: Interpolation .txt-File Format Error: 9048</title>
   <url>http://www.comsol.eu/shared/images/logos/comsol_logo.gif</url>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/</link>
  </image>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9608</link>
   <description>Hi&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
my only comment, when you have usefull suggestions, document them by explaining why etc and send them to Comsol Support so that they canbe introduced into the improvements for next version. I'm doing it regularly and it works :)&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Good luck&lt;br /&gt;&#13;
Ivar</description>
   <pubDate>Wed, 10 Mar 2010 05:38:45 +0000</pubDate>
   <guid isPermaLink="false">3392.1268199525.9608</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9601</link>
   <description>&lt;div class=&quot;quote&quot;&gt;&lt;br /&gt;&#13;
 For example, to define the function f(x, y, z) = xysin(z) on a unit-cube grid and prepare it for export to COMSOL Multiphysics, type the following on the MATLAB command line:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
x = 0:0.1:1; y = 0:0.1:1; z = 0:0.1:1;&lt;br /&gt;&#13;
[xx,yy,zz] = meshgrid(x,y,z);&lt;br /&gt;&#13;
data = xx.*yy.*sin(zz);&lt;br /&gt;&#13;
f.x = x; f.y = y; f.z = z; f.data = data;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
----------------------------------------&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;/div&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I would be usefull to have an automated method, to import functions prepared in this way, into Comsol.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
To import functions one at a time from the comsol GUI is time consuming and mistake-prone.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Maybe the best way is to import from file constructed to contain the date for all the functions.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
The command &amp;quot;postwriteinterpfile&amp;quot; creates the datafile for one function only, but thet can be joined.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
</description>
   <pubDate>Tue, 09 Mar 2010 19:31:00 +0000</pubDate>
   <guid isPermaLink="false">3392.1268163060.9601</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9443</link>
   <description>Hi again&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Now to come back to the example of the function defined in matlab: my way in these situations is always to generate an example in the Comsol GUI and then to look at it in Matlab, before I create anything the opposite way, then what I see is that (V3.5a):&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
the data in fem.functions.x .y and .data are structures with a cell for each number saved in an ascii representation and not an array of numbers, this is probably why COMSOL is not happy. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
As ASCII values the expression can be evaluated further by COMSOL, in case it is a full expression with variable names an not just numbers&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
There are more in the &amp;quot;Variables and Expressions&amp;quot; section of the help file with a few matlab examples too&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
This is what I get for two simple function defined in the comsol GUI taken from the saved .m file:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
% Functions&lt;br /&gt;&#13;
clear fcns&lt;br /&gt;&#13;
fcns{1}.type='interp';&lt;br /&gt;&#13;
fcns{1}.name='tst';&lt;br /&gt;&#13;
fcns{1}.method='piecewisecubic';&lt;br /&gt;&#13;
fcns{1}.extmethod='interior';&lt;br /&gt;&#13;
fcns{1}.x={'1','2','3','4'};&lt;br /&gt;&#13;
fcns{1}.data={'1','4','9','16'};&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
fcns{2}.type='piecewise';&lt;br /&gt;&#13;
fcns{2}.name='tstpcw(x)';&lt;br /&gt;&#13;
fcns{2}.extmethod='const';&lt;br /&gt;&#13;
fcns{2}.subtype='general';&lt;br /&gt;&#13;
fcns{2}.expr={'x^2','x^3'};&lt;br /&gt;&#13;
fcns{2}.intervals={'0','1','2'};&lt;br /&gt;&#13;
fcns{2}.complex='false';&lt;br /&gt;&#13;
fcns{2}.linear='false';&lt;br /&gt;&#13;
fem.functions = fcns;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
for 2 variable functions the data must be sorted along the formatof a &amp;quot;meshgrid&amp;quot; call see help file:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
here is an excerb of my help file, but I agree there is nothing stated about the special format of the .x, .y, .z not .data&lt;br /&gt;&#13;
-------------------------&lt;br /&gt;&#13;
To retrieve data from MATLAB, create a structure on the command line with the fields x, y (optional), z (optional), data, and elem (optional). For structured data, x, y, and z are vectors specifying the grid, and data is a multidimensional array of the same format as produced by the function call [xx,yy,zz] = meshgrid(x,y,z);. For example, to define the function f(x, y, z) = xysin(z) on a unit-cube grid and prepare it for export to COMSOL Multiphysics, type the following on the MATLAB command line:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
x = 0:0.1:1; y = 0:0.1:1; z = 0:0.1:1;&lt;br /&gt;&#13;
[xx,yy,zz] = meshgrid(x,y,z);&lt;br /&gt;&#13;
data = xx.*yy.*sin(zz);&lt;br /&gt;&#13;
f.x = x; f.y = y; f.z = z; f.data = data;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
----------------------------------------&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Hope this helps further on the way&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Good luck&lt;br /&gt;&#13;
Ivar</description>
   <pubDate>Fri, 05 Mar 2010 20:22:20 +0000</pubDate>
   <guid isPermaLink="false">3392.1267820540.9443</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9440</link>
   <description>Hi&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Maple is not really required, I still find it usefull for PDE verification. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Now to interface easily Matlab and Comsol, at a low level, one must master fully the structures and its rules and methods in Matlab (something I forget quickly if I'm not regularly using them). Tht's what I ment&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Good luck&lt;br /&gt;&#13;
Ivar&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
</description>
   <pubDate>Fri, 05 Mar 2010 19:32:48 +0000</pubDate>
   <guid isPermaLink="false">3392.1267817568.9440</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9439</link>
   <description>So it will be easier to create these data formats with Maple&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
for automated interpolation function import in COMSOL.</description>
   <pubDate>Fri, 05 Mar 2010 17:23:19 +0000</pubDate>
   <guid isPermaLink="false">3392.1267809799.9439</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9395</link>
   <description>Hi&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I do not have a direct answer, but dealing with the matlab structures is often confusing in the beginning, at least it is still for me ;)&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
if you do a search of &amp;quot;struct&amp;quot;, &amp;quot;postinterp&amp;quot;, posteval&amp;quot; on the forum you will find several examples, some answered other not, this could help you on the way.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
A working example of another issue (not exactly what you are looking after) is towards the bottom of thread &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
http://www.comsol.com/community/forums/general/thread/287/ &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Good luck&lt;br /&gt;&#13;
Ivr</description>
   <pubDate>Fri, 05 Mar 2010 12:43:01 +0000</pubDate>
   <guid isPermaLink="false">3392.1267792981.9395</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9391</link>
   <description>Some help with this data conversion will be much appreciated.&lt;br /&gt;&#13;
</description>
   <pubDate>Fri, 05 Mar 2010 12:01:18 +0000</pubDate>
   <guid isPermaLink="false">3392.1267790478.9391</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9388</link>
   <description>I have tried it quite the same way first.&lt;br /&gt;&#13;
You just have to convert the matrizes the correct way: in matlab you can store them as normal numerical arrays or as cell arrays. You need to store the data as strings in cell arrays!&lt;br /&gt;&#13;
x={'0' '1' '2' '3'} would be correct.&lt;br /&gt;&#13;
There are some functions to convert the data:&lt;br /&gt;&#13;
have a look at the matlab help for cell(), mat2cell(), num2cell() ... &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Christian&lt;br /&gt;&#13;
</description>
   <pubDate>Fri, 05 Mar 2010 09:25:37 +0000</pubDate>
   <guid isPermaLink="false">3392.1267781137.9388</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9385</link>
   <description>I would like to import many functions to COMSOL an easy way.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Therefore I made the following experiment&lt;br /&gt;&#13;
to create a function interpfun1(x,y)&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
export the fem structure to matlab.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Run the following code:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
x=[0 1 2 3]&lt;br /&gt;&#13;
y=[0 1 2 3]&lt;br /&gt;&#13;
data=[1.1 1.4 1.7 1.9; 1.6 1.7 1.8 1.9; 1.4 1.3 1.2 1.1; 1.1 1.2 1.3 1.4]&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
fem.functions{1}.type = 'interp';&lt;br /&gt;&#13;
fem.functions{1}.name = 'interpfun1';&lt;br /&gt;&#13;
fem.functions{1}.method = ''linear';&lt;br /&gt;&#13;
fem.functions{1}.extmethod = 'linear';&lt;br /&gt;&#13;
fem.functions{1}.x = x&lt;br /&gt;&#13;
fem.functions{1}.y = y&lt;br /&gt;&#13;
fem.functions{1}.data = data&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Then import the fem structure again.&lt;br /&gt;&#13;
Unfortunately I get the following error message:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&amp;quot;Not a cell array.&lt;br /&gt;&#13;
-Field: fem.functions{1}.x&amp;quot;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
What is wrong?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Is this  method generally the the right one?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
(I am very new to Matlab and COMSOL)</description>
   <pubDate>Fri, 05 Mar 2010 09:09:53 +0000</pubDate>
   <guid isPermaLink="false">3392.1267780193.9385</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9266</link>
   <description>Hi&lt;br /&gt;&#13;
Then probably you do not need to solve fully, a &amp;quot;Solve get initial conditions&amp;quot; is enought to full the matrices to do most postprocessing, I use it very often to check my initial conditions, or to do gemetrical checks by allowing volume and inertia calculations based on the meshed volumes. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
This is very handy when a normal solve can take an hour or more&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Hope this options remains in to come V4 ;)&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Good luck&lt;br /&gt;&#13;
Ivar</description>
   <pubDate>Wed, 03 Mar 2010 17:44:30 +0000</pubDate>
   <guid isPermaLink="false">3392.1267638270.9266</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9235</link>
   <description>The 'plot...' button exsists (at least in my version) only for analytic functions. But after solving you can plot it with: Postprocessing -&amp;gt; Domain plot parameters -&amp;gt; surface: functionname.&lt;br /&gt;&#13;
</description>
   <pubDate>Wed, 03 Mar 2010 08:13:14 +0000</pubDate>
   <guid isPermaLink="false">3392.1267603994.9235</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9224</link>
   <description>Hi&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
in Options Functions you have a &amp;quot;plot&amp;quot; button lower right&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I believe that even more is coming in V4&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Ivar</description>
   <pubDate>Wed, 03 Mar 2010 05:36:01 +0000</pubDate>
   <guid isPermaLink="false">3392.1267594561.9224</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9206</link>
   <description>Is there an easy way to generate a plot of a function defined in this way, to confirm that the data file is imported and interpretated correctly?</description>
   <pubDate>Tue, 02 Mar 2010 21:36:28 +0000</pubDate>
   <guid isPermaLink="false">3392.1267565788.9206</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9053</link>
   <description>I have got it. I just didn't delete one older function and didn't recognised, that Comsol wants to analyse functions also if they aren't actually used. So I had it correct for quite a while.&lt;br /&gt;&#13;
At least the small example is working fine now.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Best regards, Christian&lt;br /&gt;&#13;
</description>
   <pubDate>Mon, 01 Mar 2010 08:34:23 +0000</pubDate>
   <guid isPermaLink="false">3392.1267432463.9053</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p9050</link>
   <description>I'm back at work on this topic and am still searching for a solution. I tried different names as well and still get the same error message when i press the &amp;quot;update model&amp;quot; button:&lt;br /&gt;&#13;
&amp;quot;Exception:&lt;br /&gt;&#13;
	com.femlab.jni.FlNativeException: Format of data file is not correct&lt;br /&gt;&#13;
Messages:&lt;br /&gt;&#13;
	Format of data file is not correct&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Stack trace:&lt;br /&gt;&#13;
	at interputil.cpp, row 636, ()&lt;br /&gt;&#13;
	at com.femlab.xmesh.Xmesh.addElems(Native Method)&lt;br /&gt;&#13;
	at com.femlab.xmesh.Xmesh.addElems(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.commands.MeshExtendCommand.c(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.commands.MeshExtendCommand.s(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.commands.MeshExtendCommand.evalOnServer(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.commands.FlCommand.runServerCode(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.server.ServerProxy.eval(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.commands.FlCommand.a(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.commands.FlCommand.eval(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.commands.a.a(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.util.CoreUtil.meshExtend(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.api.client.Solver.solve(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.api.client.SolveModel.solveNow(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.api.client.SolveModel.solveNow(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.api.client.ah.a(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.gui.FlProgressThread.run(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.util.i.run(Unknown Source)&lt;br /&gt;&#13;
	at com.femlab.util.aa.run(Unknown Source)&lt;br /&gt;&#13;
&amp;quot;&lt;br /&gt;&#13;
Is there a more easy way to test my data import?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Thanks, Christian</description>
   <pubDate>Mon, 01 Mar 2010 07:46:32 +0000</pubDate>
   <guid isPermaLink="false">3392.1267429592.9050</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p8768</link>
   <description>Thanks for your suggestion. I have allready tried it with other names as well. There must be an other problem.&lt;br /&gt;&#13;
I won't be able to work on it before monday, but will contact the forum then again.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Christian</description>
   <pubDate>Wed, 24 Feb 2010 16:55:54 +0000</pubDate>
   <guid isPermaLink="false">3392.1267030554.8768</guid>
  </item>
  <item>
   <title>Re: Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p8720</link>
   <description>Hi&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
are you sure it is not your function name &amp;quot;test()&amp;quot;, I beleive this is a reserved name for COMSOL &amp;quot;test&amp;quot; function for weak variables&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Good luck&lt;br /&gt;&#13;
Ivar&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
</description>
   <pubDate>Tue, 23 Feb 2010 19:22:58 +0000</pubDate>
   <guid isPermaLink="false">3392.1266952978.8720</guid>
  </item>
  <item>
   <title>Interpolation .txt-File Format Error: 9048</title>
   <link>http://www.comsol.eu/community/forums/general/thread/3392/#p8702</link>
   <description>Hello everybody,&lt;br /&gt;&#13;
I’m trying to read a data file consisting of a matrix of measured data of an inhomogeneous refractive index (n).&lt;br /&gt;&#13;
But I’m always getting an error (# 9048) saying the format of the data file is not correct. When I try to use the data file from the rock structure example I still get the same error.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I also tried to handle the file with and without units but there is no difference.&lt;br /&gt;&#13;
The file test.txt looks like this:&lt;br /&gt;&#13;
“&lt;br /&gt;&#13;
% grid&lt;br /&gt;&#13;
0	1	2	3&lt;br /&gt;&#13;
0	1	2	3&lt;br /&gt;&#13;
% data&lt;br /&gt;&#13;
1.1	1.4	1.7	1.9&lt;br /&gt;&#13;
1.6	1.7	1.8	1.9&lt;br /&gt;&#13;
1.4	1.3	1.2	1.1&lt;br /&gt;&#13;
1.1	1.2	1.3	1.4&lt;br /&gt;&#13;
“&lt;br /&gt;&#13;
Did someone had a similar problem like me and http://www.comsol.com/community/forums/general/thread/2711/ or any suggestions?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Best Regards, Christian&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Interpolation: Options--&amp;gt;Funcions... --&amp;gt;New... Name: test, interpolation from file.&lt;br /&gt;&#13;
Use in Rectangle: n=test(x,y)</description>
   <pubDate>Tue, 23 Feb 2010 11:25:23 +0000</pubDate>
   <guid isPermaLink="false">3392.1266924323.8702</guid>
  </item>
 </channel>
</rss>

