Extracting Data at Arbitrary Points
At the MATLAB® prompt, the function mphinterp evaluates the result at arbitrary points. To evaluate an expression at specific point coordinates, call the function mphinterp as in the command:
[d1,...] = mphinterp(model,{'e1',...},'coord',<coord>)
where e1,... are the COMSOL Multiphysics expressions to evaluate, <coord> is a NxM double array, with N the space dimension of the evaluation domain, and M is the number of evaluation points. The output d1,... is a PxM double array, where P is the length of the inner solution.
Alternatively, specify the evaluation coordinates using a selection dataset:
data = mphinterp(model, <expr>, 'dataset', <dsettag>)
where <dsettag> is a selection dataset tag defined in the model, for example, Cut point, Cut Plane, Revolve, and so forth. <dsettag> can also be a mesh dataset tag, in this case the evaluation is performed on the geometric mesh vertices.
The rest of this section has additional information for the function mphinterp:
Specify the Evaluation Data
The function mphinterp supports the following properties to set the data of the evaluation to perform:
dataset, specify the solution dataset to use in the evaluation:
data = mphinterp(model,<expr>,'coord',<coord>,'dataset',<dsettag>)
<dsettag> is the tag of a solution dataset or a mesh dataset. The default value is the current solution dataset of the model. When a mesh dataset is specified the expression <expr> can only be geometry or mesh expression.
selection, specify the domain selection for evaluation:
data = mphinterp(model,<expr>,'coord',<coord>,'selection',<seltag>)
where <seltag> is the tag of a selection node to use for the data evaluation. <seltag> can also be a positive integer array that corresponds to the domain index list. The default selection is All domains where the expression is defined. If the evaluation point does not belong to the specified domain selection the output value is NaN.
edim, specify the element dimension for evaluation:
data = mphinterp(model,<expr>,'coord',<coord>,'edim',edim)
where edim is one of the strings 'point', 'edge', 'boundary' or 'domain'. One can also use numerical values instead, which in 3D are the values from 0 to 3. The default settings correspond to the model geometry space dimension. When using a lower space dimension value, make sure that the evaluation point coordinates dimension has the same size.
ext, specify extrapolation control value to define how much outside the mesh the interpolation searches. This ensures you return data for points that are outside the geometry:
data = mphinterp(model,<expr>,'coord',<coord>,'ext',<ext>)
where <ext> is a double value corresponding to the search distance as a scale in terms of the local element size. The default value is 0.1.
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 = mphinterp(model,<expr>,'coord',<coord>,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 solution respectively. By default the evaluation is performed on all inner solution.
outersolnum, specify the outer solution number for data evaluation. Outer solutions are generated with parametric sweeps:
data = mphinterp(model,<expr>,'coord',<coord>,... '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 use the first outer solution for the data evaluation.
data = mphinterp(model,<expr>,'coord',<coord>,'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 = mphinterp(model,<expr>,'coord',<coord>,'phase',<phase>)
where <phase> is a double value.
Output Format
The function mphinterp returns in the MATLAB workspace a double array. It also supports other output formats.
To evaluate several expressions at once, make sure that the same number of output variables are defined as there are expressions specified:
[d1,...] = mphinterp(model,{'e1',...},'coord',<coord>)
To extract the unit of the evaluated expression, define an extra output variable:
[data, unit] = mphinterp(model,<expr>,'coord',<coord>)
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 = mphinterp(model,<expr>,'coord',<coord>,'complexout','off')
To return an error if all evaluation points are outside the geometry, set the property coorderr to on:
data = mphinterp(model,<expr>,'coord',<coord>,'coorderr','on')
By default the function returns the value NaN for any points that are outside the domain.
Small-Signal Analysis, Prestressed Analysis, and Harmonic Perturbation Settings
For solutions with a stored linearization point, such as harmonic perturbation, small-signal analysis, or prestressed analysis you can specify the evaluation method. Use the mphinterp function with the property evalmethod:
data = mphinterp(model,<expr>,'coord',<coord>,'evalmethod',method)
where method can be one of the following value:
'harmonic', for harmonic perturbation analysis.
'linpoint', the expression is evaluated by taking the values of any dependent variables from the linearization point of the solution.
'lintotal', the expression is evaluated by adding the linearization point and the harmonic perturbation and taking the real part of this sum.
'lintotalavg', this is the same as evaluating using the lintotal property and then averaging over all phases of the harmonic perturbation.
'lintotalrms', this is the same as evaluating using the lintotal property and then taking the RMS over all phases of the harmonic perturbation.
'lintotalpeak', this is the same as evaluating using the lintotal property solution and then taking the maximum over all phases of the harmonic perturbation.
If the property evalmethod is set to harmonic, you specify whether the expression should be linearized or not with the property differential as shown below:
data = mphinterp(model,<expr>,'coord',<coord>,...
'evalmethod','harmonic','differential',diffvalue)
The default property value settings ('on') evaluates the differential of the expression with respect to the perturbation at the linearization point. If diffvalue is off, it evaluates the expression by taking the values of any dependent variables from the harmonic perturbation part of the solution.
Specify the Evaluation Quality
With the property recover, you can specify the accurate derivative recovery:
data = mphinterp(model,<expr>,'coord',<coord>,'recover',recover)
where recover is either 'ppr', 'pprint', or 'off' (the default). Set the property to ppr to perform recovery inside domains or set to pprint to apply recovery to all domain boundaries. Because the accurate derivative processing takes time, the property is disabled by default.
Other Evaluation Properties
Set the unit property to specify the unit of the evaluation:
data = mphinterp(model,<expr>,'coord',<coord>,'unit',<unit>)
where unit is a cell array with the same size as expr.
To not use complex-value functions with real inputs, use the property complexfun:
data = mphinterp(model,<expr>,'coord',<coord>,'complexfun','off')
The default value uses complex-value functions with real inputs.
Use the property matherr to return an error for undefined operations or expressions:
data = mphinterp(model,<expr>,'coord',<coord>,'matherr','on')