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.

converting COMSOL code to the MATLAB ???

Please login with a confirmed email address before reporting spam

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 :)

5 Replies Last Post 2012年6月1日 GMT-4 10:20

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年4月26日 GMT-4 09:31
Hi
you can simply save your comsol model as a MATLAB m.file

In the comsol file menu/ save As model mfile
Hi you can simply save your comsol model as a MATLAB m.file In the comsol file menu/ save As model mfile

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年4月26日 GMT-4 09:50
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
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

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年4月26日 GMT-4 10:00
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
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

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年4月27日 GMT-4 15:09
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!


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!

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年6月1日 GMT-4 10:20
Thanks.Good Hints.
Thanks.Good Hints.

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.