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
Posted 4 août 2009, 12:00 UTC−4 LiveLink for MATLAB Version 4.2a 8 Replies
Please login with a confirmed email address before reporting spam
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
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
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
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
Please login with a confirmed email address before reporting spam
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
Please login with a confirmed email address before reporting spam
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!
Please login with a confirmed email address before reporting spam
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
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.