converting COMSOL code to the MATLAB ???

Thread index  |  Previous thread  |  Next thread  |  Start a new discussion

RSS FeedRSS feed   |   Email notificationsTurn on email notifications   |   5 Replies   Last post: June 1, 2012 2:20pm UTC
Mariem Nefzi

Mariem Nefzi

April 26, 2012 1:21pm UTC

converting COMSOL code to the MATLAB ???

Hello,

I'm working with COMSOL to simulate a chemical experience, but it takes too much time to display the results.
So i want to find a link between comsol and matlab if i can convert the code of comsol to matlab that will be faster than using comsol alone !!!
So am asking if i can do this and how ????


watting your answer
thank you very much :)

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Mohammad Goharkhah

Mohammad Goharkhah

April 26, 2012 1:31pm UTC in response to Mariem Nefzi

Re: converting COMSOL code to the MATLAB ???

Hi
you can simply save your comsol model as a MATLAB m.file

In the comsol file menu/ save As model mfile

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Mariem Nefzi

Mariem Nefzi

April 26, 2012 1:50pm UTC in response to Mohammad Goharkhah

Re: converting COMSOL code to the MATLAB ???

hi Mohammad ,

thank so much for your attention . i juste did what you say but when I execute the code in matlab, it doesn't work against in comsol it works very good !!
You can find out how I can solve this problem ?
thank's again

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Mohammad Goharkhah

Mohammad Goharkhah

April 26, 2012 2:00pm UTC in response to Mariem Nefzi

Re: converting COMSOL code to the MATLAB ???

Hi
Before executing the code in MATLAB, you should "run comsol with matlab"
go to the start menu/All programs/ comsol/ run comsol with matlab
then, you can run the mfile

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Francois Gregoire

Francois Gregoire

April 27, 2012 7:09pm UTC in response to Mariem Nefzi

Re: converting COMSOL code to the MATLAB ???

here are the steps:

Step in Comsol:
- save model as .m

Start 'Comsol with Matlab'

Steps in Matlab:
- open the .m
- put first and last lines of the code in comments:
% function out = model
...code...
% out = model;
- at the end of the code, insert lines to extract results, here is an example for heat transfer, see the docs for mpheval:
T = mpheval(model,'T') % temperature
kx = mpheval(model,'ht.kxx') % thermal conductivity in x
- Run your .m (F5) and see the extracted data in the matlab workspace
- The postprocessing world is yours!


Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Foad Samadi

Foad Samadi

June 1, 2012 2:20pm UTC in response to Francois Gregoire

Re: converting COMSOL code to the MATLAB ???

Thanks.Good Hints.

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse


Rules and guidelines