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.

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 4 mai 2024, 09:59 UTC−4

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 15 avr. 2024, 11:02 UTC−4
Updated: 7 months ago 15 avr. 2024, 11:02 UTC−4

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: 7 months ago 23 avr. 2024, 04:13 UTC−4
Updated: 7 months ago 23 avr. 2024, 04:13 UTC−4

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: 7 months ago 30 avr. 2024, 02:45 UTC−4
Updated: 7 months ago 1 mai 2024, 16:00 UTC−4

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: 7 months ago 4 mai 2024, 09:42 UTC−4

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: 7 months ago 4 mai 2024, 09:59 UTC−4
Updated: 7 months ago 4 mai 2024, 10:00 UTC−4

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?

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.