function varargout=mphinterp(m,expr,varargin)
% MPHINTERP Evaluate expressions in arbitrary points or data sets
% 
%   [V1,V2,...VN] = MPHINTERP(MODEL,{E1,E2,...,EN},'COORD',COORD,...)
%   evaluates expressions E1,E2,...EN at the coordinates specified in the
%   double matrix coord. Evaluation is supported only on Solution Data Sets.
%   [V1,V2,...,VN] = MPHINTERP(MODEL,{E1,E2,...,EN},'DATASET',DSETNAME,...)
%   evaluates expressions E1,E2,...EN on the specifed data set DSETNAME. In
%   this case the data set needs to be of a type that defines an 
%   interpolation in itself, such as cut planes, revolve, etc...
%   [V1,V2,...VN,UNIT] = MPHINTERP(MODEL,{E1,E2,...,EN},...) returns in
%   addition the unit of the expressions.
% 
%   Valid property/value pairs include:
%   Property      Value/{Default}            Description
%   -----------------------------------------------------------------------
%   Complexfun    'off' | {'on'}             Use complex-valued functions
%                                            with real input
%   Complexout    {'off'} | 'on'             Return complex values
%   Coord         Double Array {''}          Coordinates for evaluation
%   Dataset       String {''}                Data set tag name
%   Edim          0, 1, 2, or 3 {sdim}       Element dimension
%   Matherr       {'off'} | 'on'             Error for undefined operation
%                                            or expressions
%   Outersolnum   Positive integer {1}       Solution number for parametric
%                                            sweep
%   Phase         Scalar {0}                 Phase angle in degrees
%   Recover       {'off'} | 'ppr' |          Accurate derivative recovery
%                 'pprint'
%   Selection     Integer vector |           Domain selection list
%                 {'all'}
%   Solnum        Integer vector |           Solution for evaluation
%                 'end' | {'all'}
%   T             Double array {''}          Time of evaluation
%   Unit          String {''} |              Unit to use for the evaluation
%                 Cell array
% 
%   In case of multiple expression, if the unit property is defined with a
%   string the same unit will be used for both expressions. To use 
%   different units, set the property with a cell array. In case of
%   unconsistent unit definition, the default unit will be used instead.
%   Solnum is used to select the solution number when a parametric,
%   eigenvalue or time-dependent solver has been used.
%   Outersolnum is used to  select the outer solution number when a
%   parametric sweep has been used in the study step node.
% 
%   See the entry MPHINTERP in the LiveLink for MATLAB User's Guide for
%   more information about the property/values.
% 
%   Example 1:
%     % Load heat_convection_2d.mph from the Model library:
%     model = mphload('heat_convection_2d.mph');
%     % Compute the temperature T at the center of the domain:
%     T = mphinterp(model,'T','coord',[0.3;0.5]);
% 
%   Example 2:
%     % Load cylinder_flow.mph from the Model library:
%     model = mphload('cylinder_flow.mph');
%     % Evaluate the x-velocity u and the time at different location point:
%     [u,t] = mphinterp(model,{'u','t'},'coord',[1,1.5,2;0.2,0.2,0.2]);
%     % Evaluate the pressure at different time and get the unit:
%     [p,t,unit] = mphinterp(model,{'p','t'}, 'coord',[2;0.2],...
%           't',[0:0.01:0.5,0.6:0.1:1]);
%     % Evaluate the the pressure and the time with the unit [mPa] and 
%     % [min] respectively:
%     [p,t] = mphinterp(model,{'p','t'},'coord',[2;0.2],'t',1,...
%           'unit',{'mPa','min'});
% 
%   Example 3:
%   % Load transport_and_adsorption.mph from the Model library:
%   model = mphload('transport_and_adsorption.mph');
%   % Evaluate the concentration along boundary 5 at t=2sec:
%   list = [0:1e-3:0.1,0.2:0.1:0.9,0.901:1e-3:1];
%   [c,y] = mphinterp(model,{'c','y'},'coord',list,'edim',1,...
%           'selection',5,'t',2);
% 
%   Example 4:
%   % Load stresses_in_pulley.mph from the Model Library:
%   model = mphload('stresses_in_pulley.mph');
%   % Evaluate the von mises stress at the cut point dataset cpt1:
%   [mises,n] = mphinterp(model,{'solid.mises','n'},'dataset','cpt1');
% 
%   Example 5:
%   % Load black_scholes_put.mph from the Model Library:
%   model=mphload('black_scholes_put.mph');
%   % Add a parametric sweep feature to the solver node and run the study:
%   param = model.study('std1').feature.create('param', 'Parametric');
%   param.set('pname',{'r'});
%   param.set('plist','range(0.12,0.12,0.6)');
%   model.study('std1').run;
%   % Evaluate u at x=[10,40,50] and t=9sec:
%   u = mphinterp(model,'u','coord',[10,40,50],'dataset','dset2',...
%           'outersolnum',2,'t',9);
% 
%   See also: mpheval, mphglobal, mphint

% Copyright 2010-2011 COMSOL
