COMSOL with matlab

Please login with a confirmed email address before reporting spam

Is saving a .mph as .m and running that .m enough to run a comsol model in .m? But my .m keeps being busy with no result.

If one wants to open a higher version comsol with a lower version comsol, is it possible to save that .mph with a higher version comsol as .m and open that .m to run the model?


5 Replies Last Post May 4, 2024, 9:59 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 7 months ago Apr 15, 2024, 11:02 a.m. EDT
Updated: 7 months ago Apr 15, 2024, 11:02 a.m. EDT

Hello,

I'm not sure if this is a great answer but I have COMSOL with MATLAB package. This allows me to run COMSOL on matlab with ease. Have you tried using that package?

Hello, I'm not sure if this is a great answer but I have COMSOL with MATLAB package. This allows me to run COMSOL on matlab with ease. Have you tried using that package?

Please login with a confirmed email address before reporting spam

Posted: 6 months ago Apr 23, 2024, 4:13 a.m. EDT
Updated: 6 months ago Apr 23, 2024, 4:13 a.m. EDT

Hi yes I have installed that package but I failed to run any program. Is turning on COMSOL with MATLAB only sufficient?

Hi yes I have installed that package but I failed to run any program. Is turning on COMSOL with MATLAB only sufficient?

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 6 months ago Apr 30, 2024, 2:45 a.m. EDT
Updated: 6 months ago May 1, 2024, 4:00 p.m. EDT

Hi Carl Xu

When you save a COMSOL model as an M-file all the steps that were carried out are reflected in that M-file. This means that if you solved the model while setting up the model then these calls to the solver are kept in the M-file. The reason is that sometimes a solution may depend on previous solved problems. This is often not what you want. On the File menu there is an item called "Compact History". It extracts the necessary statements that are required to give you an M-file that will give you a model at the state it is currently in, but without any solutions. After having called Compact History you can save an M-file that should be easy to run.

If you are new to LiveLink for Matlab I recommend reading the manual called "Introduction to LiveLink for Matlab"

-------------------
Lars Gregersen
Comsol Denmark
Hi Carl Xu When you save a COMSOL model as an M-file all the steps that were carried out are reflected in that M-file. This means that if you solved the model while setting up the model then these calls to the solver are kept in the M-file. The reason is that sometimes a solution may depend on previous solved problems. This is often not what you want. On the File menu there is an item called "Compact History". It extracts the necessary statements that are required to give you an M-file that will give you a model at the state it is currently in, but without any solutions. After having called Compact History you can save an M-file that should be easy to run. If you are new to LiveLink for Matlab I recommend reading the manual called "Introduction to LiveLink for Matlab"

Please login with a confirmed email address before reporting spam

Posted: 6 months ago May 4, 2024, 9:42 a.m. EDT

Dr Gregersen, Thank you very much for your suggestion. Whenever I run .m (saved from .mph) in comsol with matlab, matlab shows "busy" on the bottom left which means it is running. But after a while (= The time needed for the simulation), matlab reports errors (only a snippet below)

test Error using test Java exception occurred: Exception:

com.comsol.util.exceptions.FlException: Syntax error in expression

Messages:

Syntax error in expression.
Dr Gregersen, Thank you very much for your suggestion. Whenever I run .m (saved from .mph) in comsol with matlab, matlab shows "busy" on the bottom left which means it is running. But after a while (= The time needed for the simulation), matlab reports errors (only a snippet below) >> test Error using test Java exception occurred: Exception: com.comsol.util.exceptions.FlException: Syntax error in expression Messages: Syntax error in expression.

Please login with a confirmed email address before reporting spam

Posted: 6 months ago May 4, 2024, 9:59 a.m. EDT
Updated: 6 months ago May 4, 2024, 10:00 a.m. EDT

Sometimes I am lucky enough to be able to successfully run an m file, after matlab stops being busy, no plot or no new mph file is ever created. Then where is the result stored?

Sometimes I am lucky enough to be able to successfully run an m file, after matlab stops being busy, no plot or no new mph file is ever created. Then where is the result stored?

Reply

Please read the discussion forum rules before posting.

Please log in to post a reply.

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.