function varargout=mphglobal(m,expr,varargin)
% MPHGLOBAL Evaluate global quantities
% 
%   [D1,D2,...,DN] = MPHGLOBAL(MODEL,{E1,E2,...,EN},...) returns the
%   results from evaluating the global quantities specified in the string 
%   expressions E1,E2,...,EN.
%
%   [D1,D2,...,DN,UNIT] = MPHGLOBAL(MODEL,{E1,E2,...,EN},...) returns the 
%   results from evaluating the global quantities specified in the string 
%   expressions E1,E2,...,EN. UNIT is a Nx1 cell array that contains the 
%   unit of the different expressions evaluated.
% 
%   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
%   Dataset       String {''}            Data set tag name
%   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
%   Solnum        Integer vector |       Solution for evaluation
%                 'end' | {'all'}
%   T             Double array {''}      Time for evaluation
%   Unit          String {''} |          Unit to use for the evaluation 
%                 Cell array   
% 
%   See the entry MPHGLOBAL in the LiveLink for MATLAB User's Guide for 
%   more information about the property/values.
% 
%   Example 1:
%     % Load fluid_valve.mph from the Model Library: 
%     model = mphload('fluid_valve.mph');
%     % Evaluate the global expression u_up for each time step:
%     u_up = mphglobal(model,'u_up');
%     % Evaluate the global expression u_up at t=0.8sec:
%     u_up = mphglobal(model,'u_up','t',0.8);
%     % Evaluate the expressions u_up and u_down at the last solution 
%     % number:
%     [u_up,u_down] = mphglobal(model,{'u_up','u_down'},'solnum','end');
%     % Evaluate the expression u_up in mm^2/s and u_down in cm^2/s:
%     [u_up u_down] = mphglobal(model,{'u_up' 'u_down'},...
%        'unit',{'mm^2/s' 'cm^2/s'});
%     % Evaluate the expression u_up and u_down in mm/s^2 and return the 
%     % unit:
%     [u_up u_down unit] = mphglobal(model,{'u_up' 'u_down'},...
%        'unit','mm^2/s');
% 
%   Example 2:
%     % Load black_scholes_put.mph from the Model Library:
%     model=mphload('black_scholes_put.mph');
%     % Add an average and a maximum operator for the domain 1:
%     model.cpl.create('aveop1', 'Average', 'geom1');
%     model.cpl.create('maxop1', 'Maximum', 'geom1');
%     model.cpl('aveop1').selection.set(1);
%     model.cpl('maxop1').selection.set(1);
%     % 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 the maximum value of u for all time step and for r=0.12:
%     dat1 = mphglobal(model,'maxop1(u)','dataset','dset2',...
%         'outersolnum',1);
%     % Evaluate the average value of u at t=6sec for the second  value of
%     % r (r=0.24):
%     dat2 = mphglobal(model,'aveop1(u)','dataset','dset2',...
%     'outersolnum',2,'t',6); 
% 
%   See also: mpheval, mphint, mphinterp

% Copyright 2010-2011 COMSOL
