Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Import Matlab m-file back to COMSOL

Please login with a confirmed email address before reporting spam

Hi,

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.

Wan

8 Replies Last Post 21 juil. 2016, 16:31 UTC−4

Please login with a confirmed email address before reporting spam

Posted: 2 decades ago 4 août 2009, 15:10 UTC−4
Are you running the software with the COMSOL Multiphysics with MATLAB shortcut? You should see File > Import > FEM Structure.
Are you running the software with the COMSOL Multiphysics with MATLAB shortcut? You should see File > Import > FEM Structure.

Please login with a confirmed email address before reporting spam

Posted: 2 decades ago 5 août 2009, 08:56 UTC−4
It doesn't seem to import boundary conditions. Any ways to import those as well.
It doesn't seem to import boundary conditions. Any ways to import those as well.

Please login with a confirmed email address before reporting spam

Posted: 2 decades ago 5 août 2009, 15:15 UTC−4
Hi,
if you have matlab connection to comsol, you can save the m file from comsol, modify the file in matlab and then re-load the so-modified file in comsol (file>open>.mfile). Anyway, you can also export the fem structure (file>export>fem) and view the variable within the matlab workspace. If you know the fem structure with its fields you can modify it and then re-load in comsol (file>import>fem) where you can run the solution.
On the other hand, if you save the m.file you can run the model directly from matlab (without using comsol again).

If you do not delete or modify the field fem{1}.appl.bnd, boundary conditions are correctly imported . You can verify it...

Good luck

Pasquale
Hi, if you have matlab connection to comsol, you can save the m file from comsol, modify the file in matlab and then re-load the so-modified file in comsol (file>open>.mfile). Anyway, you can also export the fem structure (file>export>fem) and view the variable within the matlab workspace. If you know the fem structure with its fields you can modify it and then re-load in comsol (file>import>fem) where you can run the solution. On the other hand, if you save the m.file you can run the model directly from matlab (without using comsol again). If you do not delete or modify the field fem{1}.appl.bnd, boundary conditions are correctly imported . You can verify it... Good luck Pasquale

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 9 mars 2011, 09:17 UTC−5

Are you running the software with the COMSOL Multiphysics with MATLAB shortcut? You should see File > Import > FEM Structure.


This is not valid anymore in COMSOL 4.1
[QUOTE] Are you running the software with the COMSOL Multiphysics with MATLAB shortcut? You should see File > Import > FEM Structure. [/QUOTE] This is not valid anymore in COMSOL 4.1

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 21 avr. 2011, 10:13 UTC−4

Hi,
if you have matlab connection to comsol, you can save the m file from comsol, modify the file in matlab and then re-load the so-modified file in comsol (file>open>.mfile). Anyway, you can also export the fem structure (file>export>fem) and view the variable within the matlab workspace. If you know the fem structure with its fields you can modify it and then re-load in comsol (file>import>fem) where you can run the solution.
On the other hand, if you save the m.file you can run the model directly from matlab (without using comsol again).

If you do not delete or modify the field fem{1}.appl.bnd, boundary conditions are correctly imported . You can verify it...

Good luck

Pasquale


Hi,

I am using V3.5a. After exporting an m file from COMSOL to Matlab, I can see the changes that I make in COMSOL's GUI are implemented in MATLAB's script. But I cannot do the other way around, i.e. after I make a modification in the geometry in MATLAB script, I save the m file and open it in COMSOL, and I get this error:

Error: 9040
Fatal Error.
Type: NullPointerException

Any idea why this happens?

Thanks,
Manuel
[QUOTE] Hi, if you have matlab connection to comsol, you can save the m file from comsol, modify the file in matlab and then re-load the so-modified file in comsol (file>open>.mfile). Anyway, you can also export the fem structure (file>export>fem) and view the variable within the matlab workspace. If you know the fem structure with its fields you can modify it and then re-load in comsol (file>import>fem) where you can run the solution. On the other hand, if you save the m.file you can run the model directly from matlab (without using comsol again). If you do not delete or modify the field fem{1}.appl.bnd, boundary conditions are correctly imported . You can verify it... Good luck Pasquale [/QUOTE] Hi, I am using V3.5a. After exporting an m file from COMSOL to Matlab, I can see the changes that I make in COMSOL's GUI are implemented in MATLAB's script. But I cannot do the other way around, i.e. after I make a modification in the geometry in MATLAB script, I save the m file and open it in COMSOL, and I get this error: Error: 9040 Fatal Error. Type: NullPointerException Any idea why this happens? Thanks, Manuel

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 25 janv. 2012, 06:11 UTC−5


Hi,
if you have matlab connection to comsol, you can save the m file from comsol, modify the file in matlab and then re-load the so-modified file in comsol (file>open>.mfile). Anyway, you can also export the fem structure (file>export>fem) and view the variable within the matlab workspace. If you know the fem structure with its fields you can modify it and then re-load in comsol (file>import>fem) where you can run the solution.
On the other hand, if you save the m.file you can run the model directly from matlab (without using comsol again).

If you do not delete or modify the field fem{1}.appl.bnd, boundary conditions are correctly imported . You can verify it...

Good luck

Pasquale


Hi,

I am using V3.5a. After exporting an m file from COMSOL to Matlab, I can see the changes that I make in COMSOL's GUI are implemented in MATLAB's script. But I cannot do the other way around, i.e. after I make a modification in the geometry in MATLAB script, I save the m file and open it in COMSOL, and I get this error:

Error: 9040
Fatal Error.
Type: NullPointerException

Any idea why this happens?

Thanks,
Manuel


Hi

I am facing the same problem.. I am using Comsol 4.2a and matlab 2008a and when i save the changes in the Matlab m-file for the comsol model, it does not recognize the changed parameters. Also, does anyone know how i can use matlab variables in a Matlab-Simulink-Comsol interface problem where i declare a comsol variable = a time dependent matlab variable through the simulink sfunction. so basically i cannot use the matlab functions through livelink and i need to use the matlab variables.

any sort of help would be appreciated. thanks a lot!
[QUOTE] [QUOTE] Hi, if you have matlab connection to comsol, you can save the m file from comsol, modify the file in matlab and then re-load the so-modified file in comsol (file>open>.mfile). Anyway, you can also export the fem structure (file>export>fem) and view the variable within the matlab workspace. If you know the fem structure with its fields you can modify it and then re-load in comsol (file>import>fem) where you can run the solution. On the other hand, if you save the m.file you can run the model directly from matlab (without using comsol again). If you do not delete or modify the field fem{1}.appl.bnd, boundary conditions are correctly imported . You can verify it... Good luck Pasquale [/QUOTE] Hi, I am using V3.5a. After exporting an m file from COMSOL to Matlab, I can see the changes that I make in COMSOL's GUI are implemented in MATLAB's script. But I cannot do the other way around, i.e. after I make a modification in the geometry in MATLAB script, I save the m file and open it in COMSOL, and I get this error: Error: 9040 Fatal Error. Type: NullPointerException Any idea why this happens? Thanks, Manuel [/QUOTE] Hi I am facing the same problem.. I am using Comsol 4.2a and matlab 2008a and when i save the changes in the Matlab m-file for the comsol model, it does not recognize the changed parameters. Also, does anyone know how i can use matlab variables in a Matlab-Simulink-Comsol interface problem where i declare a comsol variable = a time dependent matlab variable through the simulink sfunction. so basically i cannot use the matlab functions through livelink and i need to use the matlab variables. any sort of help would be appreciated. thanks a lot!

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 25 janv. 2012, 13:51 UTC−5
Nikita,

Have you tried the command 'mphsave'? It converts a .m to .mph, see the Livelink for Matlab User's Guide or type 'help mphsave' in Matlab. It works just fine here with comsol 4.2a and Matlab R2011a.
Nikita, Have you tried the command 'mphsave'? It converts a .m to .mph, see the Livelink for Matlab User's Guide or type 'help mphsave' in Matlab. It works just fine here with comsol 4.2a and Matlab R2011a.

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 21 juil. 2016, 16:31 UTC−4
How to import comsol model into simulink (Matlab)?
How to import comsol model into simulink (Matlab)?

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.