Evaluating a Global Expression
Evaluate a global expression with the function mphglobal.
To evaluate a global expression at the MATLAB® prompt, call the function mphglobal as in this command:
[d1,...] = mphglobal(model,{'e1',...})
where e1,... are the COMSOL Multiphysics global expressions to evaluate. The output values d1,... are returned as a Px1 double array, with P the length of inner parameters.
The rest of this section has additional information for the function mphglobal:
Specify the Evaluation Data
The function mphglobal supports the following properties to set the data of the evaluation to perform:
dataset, specify the solution dataset to use in the evaluation:
data = mphglobal(model,<expr>,'dataset',<dsettag>)
<dsettag> is the tag of a solution dataset. The default value is the current solution dataset of the model.
solnum, specify the inner solution number for data evaluation. Inner solutions are generated for the following analysis types: time domain, frequency domain, eigenvalue, or stationary with continuation parameters:
data = mphglobal(model,<expr>,'solnum',<solnum>)
where <solnum> is an integer array corresponding to the inner solution index. <solnum> can also be a string:'end' or 'all' to evaluate the expression for the last inner solution or all inner solutions, respectively. By default the evaluation is performed on all inner solutions.
outersolnum, specify the outer solution number for data evaluation. Outer solutions are generated with parametric sweeps:
data = mphglobal(model,<expr>,'outersolnum',<outersolnum>)
where <outersolnum> is a positive integer corresponding to the outer solution index. <outersolnum> can also be a string, 'all' or 'end' to evaluate the expression for all or the last outer solution, respectively. The default settings uses the first outer solution for the data evaluation.
data = mphglobal(model,<expr>,'t',<time>)
where <time> is a double array. The default value corresponds to all the stored time steps.
phase, specify the phase in degrees:
data = mphglobal(model,<expr>,'phase',<phase>)
where <phase> is a double value.
Output Format
The function mphglobal also supports other output formats.
To extract the unit of the evaluated expression, define an extra output variable:
[data,unit] = mphglobal(model,<expr>)
with unit is a 1xN cell array where N is the number of expressions to evaluate.
Returns only the real part in the data evaluation with the property complexout:
data = mphglobal(model,<expr>,'complexout','off')
Other Evaluation Properties
Set the unit property to specify the unit of the evaluation:
data = mphglobal(model,<expr>,'unit',<unit>)
where <unit> is a cell array with the same length as <expr>.
Use the property matherr to return an error for undefined operations or expressions:
data = mphglobal(model,<expr>,'matherr','on')