mphplot
Render a plot group in a figure window.
Syntax
mphplot(model)
mphplot(model,pgtag,...)
pd = mphplot(model,pgtag,...)
mphplot(pd,...)
Description
mphplot(model) opens a figure window and adds a menu where it is possible to switch between all the different result plots in a model as well as any geometry and mesh plots. A toolbar is added to the figure that allows the user to control the use of views, lights, and camera settings.
mphplot(model,pgtag,...) renders the plot group tagged pgtag from the model object model in a figure window in MATLAB®.
pd = mphplot(model,pgtag,...) also returns the plot data used in the MATLAB figure in a cell array pd. pd contains ordinary MATLAB data and can later be used to recreate the plot using mphplot. It is also possible to investigate and extract data from the plot this way in order to create plots in other ways or to further analyze the data. Set createplot to off if a plot should be not be created. Note that pd contains data in single precision even though all calculations in COMSOL Multiphysics are carried out in double precision.
mphplot(pd,...) makes a plot using the post data structure pd that is generated using the function mpheval. Plots involving points, lines and surfaces are supported.
The function mphplot accepts the following property/value pairs:
on | off
on | off
on | off
char | 'auto' | ''
Note: The plot on server option requires that you start COMSOL with MATLAB in graphics mode.
Only one color range bar and one legend bar is supported in a MATLAB figure. When the option plot on server is active, all active color range bar are displayed.
The property createplot is useful when extracting plot data structure on machines without a graphics display.
The data fields returned by mphplot are subject to change. The most important fields are:
p, the coordinates for each point that are used for creating lines or triangles.
n, the normals in each point for the surfaces. These are not always available.
t, contains the indices to columns in p of a simplex mesh, each column in t representing a simplex.
d, the data values for each point.
rgb, the color values (red, green and blue) entities at each point.
Example
Display the plot settings pg using a MATLAB figure
model = mphopen('model_tutorial_llmatlab');
std = model.study.create('std');
std.feature.create('stat','Stationary');
std.run;
model.result.dataset.create('mir', 'Mirror3D');
pg = model.result.create('pg', 'PlotGroup3D');
pg.set('data', 'mir');
surf1 = pg.feature.create('surf1', 'Surface');
surf1.set('colortable', 'Thermal');
mphplot(model,'pg')
Combine plot types on the same plot group:
surf2 = pg.feature.create('surf2', 'Surface');
surf2.set('data', 'dset1');
surf2.set('expr', 'ht.tfluxMag');
Display the plot group and the color range bar of the second plot type:
mphplot(model,'pg','rangenum',2)
Display the plot group on the server:
mphplot(model,'pg','server','on')
Display expression value evaluated using mpheval:
model = mphopen('model_tutorial_llmatlab');
std = model.study.create('std');
std.feature.create('stat','Stationary');
std.run;
Extract temperature and total heat flux magnitude in domain 2:
pd = mpheval(model,{'T','ht.tfluxMag'},'selection',2);
Plot the temperature data using thermal color table:
mphplot(pd,'index',1,'colortable','Thermal','rangenum',1)
See also
colortable, mpheval