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.

How to convert comsol plots into matlab plots

Please login with a confirmed email address before reporting spam

hi,
how to convert comsol plots into matlab plots? i am using comsol v 4.1 earlier i was using v3.4 in which i could easily get the cordinates of the plot, but i am not able to find that option in V4.1
plz help....

3 Replies Last Post 2016年6月27日 GMT-4 07:30

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2011年2月4日 GMT-5 05:43
Hi,

this requires, that you connect Matlab to the Comsol server.
In linux it would be the command "comsol matlab server".

Alternatively you can also start Matlab first, then add the path <dir>/COMSOL41/mli (where <dir> is the architecture root directory).

Here is a list of commands, which you should execute in Matlab/Comsol:

In Matlab:
1. addpath <dir>/COMSOL41/mli
2. mphstart
3. import com.comsol.model.*

4. import com.comsol.model.util.*


Then in Comsol "File -> Export Model to Server" and give your model a NAME
Back in Matlab: model = ModelUtil.model('NAME');

Now the model is in your workspace.
With the command mphplot (check the documentation on this for the syntax and options) you can access any plot group of your comsol model and create a matlab plot.
There are some other useful commands that start with "mph" that might be of interest for you.

Hope this helps,
Juergen
Hi, this requires, that you connect Matlab to the Comsol server. In linux it would be the command "comsol matlab server". Alternatively you can also start Matlab first, then add the path /COMSOL41/mli (where is the architecture root directory). Here is a list of commands, which you should execute in Matlab/Comsol: In Matlab: 1. addpath /COMSOL41/mli 2. mphstart 3. import com.comsol.model.* 4. import com.comsol.model.util.* Then in Comsol "File -> Export Model to Server" and give your model a NAME Back in Matlab: model = ModelUtil.model('NAME'); Now the model is in your workspace. With the command mphplot (check the documentation on this for the syntax and options) you can access any plot group of your comsol model and create a matlab plot. There are some other useful commands that start with "mph" that might be of interest for you. Hope this helps, Juergen

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年6月26日 GMT-4 04:03
hi
I tried your solution but I got an error as below:

Undefined variable "ModelUtil" or class "ModelUtil.model".
hi I tried your solution but I got an error as below: Undefined variable "ModelUtil" or class "ModelUtil.model".

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年6月27日 GMT-4 07:30
Hi

In recent versions of Comsol you can simply do

pd = mphplot(model, 'pg1');

and then pd is a struct variable that contains all the necessary settings for recreating the plot in Matlab.

Note that this requires LiveLink for Matlab.


--
Lars Gregersen
Comsol Denmark
Hi In recent versions of Comsol you can simply do pd = mphplot(model, 'pg1'); and then pd is a struct variable that contains all the necessary settings for recreating the plot in Matlab. Note that this requires LiveLink for Matlab. -- Lars Gregersen Comsol Denmark

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.