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.

Control Comsol with Matlab

Please login with a confirmed email address before reporting spam

Hi to all
i"m using comsol 4.1 matlab 2011b

comsol with matlab.

attached
the view of my comsol model in matlab after i run it

my qeustion are:

how can i control or use this model in matlab?
can i do a parametric sweep using matlab?
can i see somhow the results make plots of it?
how can i see my results? in matlab? in comsol?

can i change the geometry in matlab and see the change in comsol?

i really would like to be guided or helped or read from a nice guide document

are there some examples for me that someone could send then they used comsol with matlab?

thanks a lot
best regards,
Arye Nudelman


5 Replies Last Post Sep 29, 2011, 7:51 p.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 6, 2011, 11:28 a.m. EDT
your questions are:

==================

a) how can i control or use this model in matlab?
b) can i do a parametric sweep using matlab?
c) can i see somhow the results make plots of it?
d) how can i see my results? in matlab? in comsol?
e) can i change the geometry in matlab and see the change in comsol?
f) i really would like to be guided or helped or read from a nice guide document

===================


I'm not sure anyone here will explain in details how to do such things, because you should learn it by making simple examples on your own, and read the Users Guide. however, I'll give you some tips that will help you:

Open "Matlab with COMSOL41" and also open another "COMSOL41" (not with matlab). When you run a script in MATLAB livelink, you can see the resulting model in the independent COMSOL41 window in File->import model, etc.... Then you can see if everything is ok when you make some change in your Matlab script file.

answer to your questions:

a) Save your model in COMSOL as a matlab file. Then open this file with a "Matlab with COMSOL41" session. You will be able to find how the model is set and you can make your own change there.
b) Add a parametric sweep node in your COMSOL file, save your file as a Matlab file and look at the new code that has been generated compared to the previous script without parametric sweep.
c) look in the userguide about the matlab function "mphplot"
d) same answer
e) run your new script file (with the new geometry) and then import it in an independant COMSOL41 session (as explained above)
f) User Guide, open "Help" in COMSOL 4.1

I hope it will help you

----------------
Frank
your questions are: ================== a) how can i control or use this model in matlab? b) can i do a parametric sweep using matlab? c) can i see somhow the results make plots of it? d) how can i see my results? in matlab? in comsol? e) can i change the geometry in matlab and see the change in comsol? f) i really would like to be guided or helped or read from a nice guide document =================== I'm not sure anyone here will explain in details how to do such things, because you should learn it by making simple examples on your own, and read the Users Guide. however, I'll give you some tips that will help you: Open "Matlab with COMSOL41" and also open another "COMSOL41" (not with matlab). When you run a script in MATLAB livelink, you can see the resulting model in the independent COMSOL41 window in File->import model, etc.... Then you can see if everything is ok when you make some change in your Matlab script file. answer to your questions: a) Save your model in COMSOL as a matlab file. Then open this file with a "Matlab with COMSOL41" session. You will be able to find how the model is set and you can make your own change there. b) Add a parametric sweep node in your COMSOL file, save your file as a Matlab file and look at the new code that has been generated compared to the previous script without parametric sweep. c) look in the userguide about the matlab function "mphplot" d) same answer e) run your new script file (with the new geometry) and then import it in an independant COMSOL41 session (as explained above) f) User Guide, open "Help" in COMSOL 4.1 I hope it will help you ---------------- Frank

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 6, 2011, 2:23 p.m. EDT
thank you very much
you are very clear and this is the kind of help i'm looking

i'll do what you said and come back latter with my inputs thanks alot

and a small question forward;

if i use param.txt file with parametes in my comsol model
so when i use matlab should i just save the model
as model.m file or i should put
param.txt in the same folder with my model.m file
in matlab

and is there a possibly to receive a help from you in some other comunicational way like skype or chat?
mine skype arye.nuelman

Best regards,
Arye



thank you very much you are very clear and this is the kind of help i'm looking i'll do what you said and come back latter with my inputs thanks alot and a small question forward; if i use param.txt file with parametes in my comsol model so when i use matlab should i just save the model as model.m file or i should put param.txt in the same folder with my model.m file in matlab and is there a possibly to receive a help from you in some other comunicational way like skype or chat? mine skype arye.nuelman Best regards, Arye

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 7, 2011, 2:21 p.m. EDT
thanks Frank your advice so helped me
thank you thank you

i have a lot of sucses with my model in matlab
:-))))

now my question is:

if it is possible to run my model as like it was a function

attached
for I.e the picture show i have a for in my model
but i want the for to be outside the model and to run the model
as if it is a function that the for is calling for it

Best regards,
Arye
thanks Frank your advice so helped me thank you thank you i have a lot of sucses with my model in matlab :-)))) now my question is: if it is possible to run my model as like it was a function attached for I.e the picture show i have a for in my model but i want the for to be outside the model and to run the model as if it is a function that the for is calling for it Best regards, Arye


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Sep 5, 2011, 6:08 a.m. EDT
Hi arye

I am working with same problem as you have. i have exported my mph file as model using 'mphload' and i am trying to run the model in a loop. the purpose is to run the model with varying parameters. but i am not able to save the results as it saves only the last sol.

it would be nice if someone could post a simple example on that

thanks

Hi arye I am working with same problem as you have. i have exported my mph file as model using 'mphload' and i am trying to run the model in a loop. the purpose is to run the model with varying parameters. but i am not able to save the results as it saves only the last sol. it would be nice if someone could post a simple example on that thanks

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Sep 29, 2011, 7:51 p.m. EDT
There are detailed examples of models in Matlab, including models run in loops, in the LiveLink for Matlab Users Guide (pdf). I believe that is why no one is bothering to answer you on the forums.

Check out page 35 for running models in loops. Hope this helps, I am a COMSOL noob myself.
There are detailed examples of models in Matlab, including models run in loops, in the LiveLink for Matlab Users Guide (pdf). I believe that is why no one is bothering to answer you on the forums. Check out page 35 for running models in loops. Hope this helps, I am a COMSOL noob myself.

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.