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.

mphplot(model, 'pg1') command does not work

Please login with a confirmed email address before reporting spam

Hi,

I am very new user of COMSOL. I am using COMSOL 51. and COMSOL 5.1 with Matlab.

I have a comsol model in comsol GUI. It has a 2D plot with a tag <pg1>. I want to see the graph in matlab.
At first I opened Comsol with matlab. Then I wrote a code to import the comsol model. Everything works fine. But when I try to plot the graph by the command mphplot(model, 'pg1'), it shows error.
My code is like bellow

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

model=mphload('Rahman.mph'); %Rahman is the name of the model
info=mphsolinfo(model, 'solname', 'sol1');
tlist=info.solvals;
pd=mpheval(model, 'c'); % c is the dependent variable.
mphplot(model, 'pg1');

I would like to see the graph in matalb. But matlab is showing that there is an error in line mphplot.
Does anybody knoe how to use the mphplot command correctly?? Thanks in advance.

8 Replies Last Post 07.10.2015, 07:55 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 17.09.2015, 12:00 GMT-4
Your code looks correct. Matlab doesn't load the current model you are working with, only what is saved to the hard drive. Make sure you save your .mph file after you create your plot, then run mphload and mph plot.

If this isn't the issue, please copy and paste the details of your error so we can have a look.

Best of luck,
Alex Mertz
Your code looks correct. Matlab doesn't load the current model you are working with, only what is saved to the hard drive. Make sure you save your .mph file after you create your plot, then run mphload and mph plot. If this isn't the issue, please copy and paste the details of your error so we can have a look. Best of luck, Alex Mertz

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 18.09.2015, 04:43 GMT-4
Thanks for your comment.
I have saved the mph file and then I wrote command in Matlab script. But it does not show the plot rather it shows error and a blank graph (Please see attachment: Matlab_figure). But the actual plot of comsol looks like the attachment 'Comsol_figure'.
The errors are given below:

Error using strcmp
Too many input arguments
Error in mphplot/1_getPT (line 485 )
Error in mphplot/geomedgeplot (line 289)
Error in mphplot (line 223)

I used only mphplot(model, 'pg1') command. I just want to render the plot to Matlab. Do you have any suggestion why I have this kind of errors ? Thanks in advance.
Thanks for your comment. I have saved the mph file and then I wrote command in Matlab script. But it does not show the plot rather it shows error and a blank graph (Please see attachment: Matlab_figure). But the actual plot of comsol looks like the attachment 'Comsol_figure'. The errors are given below: Error using strcmp Too many input arguments Error in mphplot/1_getPT (line 485 ) Error in mphplot/geomedgeplot (line 289) Error in mphplot (line 223) I used only mphplot(model, 'pg1') command. I just want to render the plot to Matlab. Do you have any suggestion why I have this kind of errors ? Thanks in advance.


Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 18.09.2015, 08:07 GMT-4
Hi

This is a bug that has been fixed in our latest update, which you can get here:
www.comsol.com/product-update/5.1


Thanks for your comment.
I have saved the mph file and then I wrote command in Matlab script. But it does not show the plot rather it shows error and a blank graph (Please see attachment: Matlab_figure). But the actual plot of comsol looks like the attachment 'Comsol_figure'.
The errors are given below:

Error using strcmp
Too many input arguments
Error in mphplot/1_getPT (line 485 )
Error in mphplot/geomedgeplot (line 289)
Error in mphplot (line 223)

I used only mphplot(model, 'pg1') command. I just want to render the plot to Matlab. Do you have any suggestion why I have this kind of errors ? Thanks in advance.



--
Lars Gregersen
Comsol Denmark
Hi This is a bug that has been fixed in our latest update, which you can get here: http://www.comsol.com/product-update/5.1 [QUOTE] Thanks for your comment. I have saved the mph file and then I wrote command in Matlab script. But it does not show the plot rather it shows error and a blank graph (Please see attachment: Matlab_figure). But the actual plot of comsol looks like the attachment 'Comsol_figure'. The errors are given below: Error using strcmp Too many input arguments Error in mphplot/1_getPT (line 485 ) Error in mphplot/geomedgeplot (line 289) Error in mphplot (line 223) I used only mphplot(model, 'pg1') command. I just want to render the plot to Matlab. Do you have any suggestion why I have this kind of errors ? Thanks in advance. [/QUOTE] -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 25.09.2015, 02:52 GMT-4

Hi

This is a bug that has been fixed in our latest update, which you can get here:
www.comsol.com/product-update/5.1


--
Lars Gregersen
Comsol Denmark


Hi Lars

i have the latest and greatest comsol version

#Version properties.
ver.build=234
ver.major=0
ver.name=COMSOL 5.1

but still i get a error when using mphplot

% create a 3D plot group
pg = model.result.create('pg','PlotGroup3D');

%create a surface plot
surf = pg.feature.create('surf', 'Surface');
surf.set('expr', 'T');

% display the plot group
mphplot(model , 'pg')


the error is the following:
Error using strcmp
Too many input arguments.

Error in mphplot/l_getPT (line 485)



Error in mphplot/geomedgeplot (line 289)



Error in mphplot (line 223)
[QUOTE] Hi This is a bug that has been fixed in our latest update, which you can get here: http://www.comsol.com/product-update/5.1 -- Lars Gregersen Comsol Denmark [/QUOTE] Hi Lars i have the latest and greatest comsol version #Version properties. ver.build=234 ver.major=0 ver.name=COMSOL 5.1 but still i get a error when using mphplot % create a 3D plot group pg = model.result.create('pg','PlotGroup3D'); %create a surface plot surf = pg.feature.create('surf', 'Surface'); surf.set('expr', 'T'); % display the plot group mphplot(model , 'pg') the error is the following: Error using strcmp Too many input arguments. Error in mphplot/l_getPT (line 485) Error in mphplot/geomedgeplot (line 289) Error in mphplot (line 223)

Jesper Been COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 28.09.2015, 05:13 GMT-4
Hi

We have created a Knowledge Base entry with an attached mphplot.p file that should solve the problem. Let us know if you are still experiencing issues.

www.comsol.com/support/knowledgebase/1214/

--
Jesper Been
COMSOL Denmark
Hi We have created a Knowledge Base entry with an attached mphplot.p file that should solve the problem. Let us know if you are still experiencing issues. https://www.comsol.com/support/knowledgebase/1214/ -- Jesper Been COMSOL Denmark

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 05.10.2015, 12:26 GMT-4
Hi there,

I've replaced the .p file, but mphplot still doesn't work. It doesn't show error message any more, but no plot is displayed either.
Hi there, I've replaced the .p file, but mphplot still doesn't work. It doesn't show error message any more, but no plot is displayed either.

Jesper Been COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 07.10.2015, 02:57 GMT-4

Hi there,

I've replaced the .p file, but mphplot still doesn't work. It doesn't show error message any more, but no plot is displayed either.


Hi,

There might be other issues with that plot then. I suggest you send a repeat model to support.
[QUOTE] Hi there, I've replaced the .p file, but mphplot still doesn't work. It doesn't show error message any more, but no plot is displayed either. [/QUOTE] Hi, There might be other issues with that plot then. I suggest you send a repeat model to support.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 07.10.2015, 07:55 GMT-4
Yes, it works after replacing the mphplot.p file as suggested! Finally....
Yes, it works after replacing the mphplot.p file as suggested! Finally....

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.