


INTERP interpolate the values in the input AO(s) at new values specified by the input parameter list.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: INTERP interpolate the values in the input AO(s) at new values
specified by the input parameter list.
CALL: b = interp(a, pl)
INPUTS: a - input array of AOs
pl - parameter list with the keys 'vertices' and 'method'
OUTPUTS: b - output array of AOs
PARAMETERS: 'vertices' - new set of vertices to interpolate on.
'method' - one of:
'nearest' - nearest neighbour
'linear' - linear interpolation
'spline' - spline interpolation
'cubic' - shape-preserving piecewise cubic interpolation
REMARK: Matrix cdata objects are not supported.
VERSION: $Id: interp.m,v 1.10 2007/11/26 14:48:13 ingo Exp $
The following call returns a parameter list object that contains the
default parameter values:
>> pl = interp(ao, 'Params')
HISTORY: 05-06-07 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 function varargout = interp(varargin) 0002 % INTERP interpolate the values in the input AO(s) at new values specified by the input parameter list. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: INTERP interpolate the values in the input AO(s) at new values 0007 % specified by the input parameter list. 0008 % 0009 % CALL: b = interp(a, pl) 0010 % 0011 % INPUTS: a - input array of AOs 0012 % pl - parameter list with the keys 'vertices' and 'method' 0013 % 0014 % OUTPUTS: b - output array of AOs 0015 % 0016 % PARAMETERS: 'vertices' - new set of vertices to interpolate on. 0017 % 'method' - one of: 0018 % 'nearest' - nearest neighbour 0019 % 'linear' - linear interpolation 0020 % 'spline' - spline interpolation 0021 % 'cubic' - shape-preserving piecewise cubic interpolation 0022 % 0023 % REMARK: Matrix cdata objects are not supported. 0024 % 0025 % VERSION: $Id: interp.m,v 1.10 2007/11/26 14:48:13 ingo Exp $ 0026 % 0027 % The following call returns a parameter list object that contains the 0028 % default parameter values: 0029 % 0030 % >> pl = interp(ao, 'Params') 0031 % 0032 % HISTORY: 05-06-07 M Hewitson 0033 % Creation 0034 % 0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0036 0037 ALGONAME = mfilename; 0038 VERSION = '$Id: interp.m,v 1.10 2007/11/26 14:48:13 ingo Exp $'; 0039 0040 % Check if this is a call for parameters 0041 if nargin == 2 0042 in = char(varargin{2}); 0043 if strcmp(in, 'Params') 0044 varargout{1} = getDefaultPL(); 0045 return 0046 elseif strcmp(in, 'Version') 0047 varargout{1} = VERSION; 0048 return 0049 end 0050 end 0051 0052 % Collect input ao's, plist's and ao variable names 0053 in_names = {}; 0054 for ii = 1:nargin 0055 in_names{end+1} = inputname(ii); 0056 end 0057 0058 [as, ps, invars] = collect_inputs(varargin, in_names); 0059 0060 % check plist 0061 if isempty(ps) 0062 pl = getDefaultPL(); 0063 else 0064 pl = combine(ps, getDefaultPL); 0065 end 0066 0067 0068 % Get parameters 0069 vertices = find(pl, 'vertices'); 0070 method = find(pl, 'method'); 0071 0072 %----------------------- 0073 % Loop over input AOs 0074 bs = []; 0075 for j=1:numel(as) 0076 0077 a = as(j); 0078 0079 %---------------------------- 0080 % Get data 0081 [x,y] = get_xy_values(a.data); 0082 0083 %---------------------------- 0084 % Interpolate this vector 0085 if ~isempty(x) 0086 % for tsdata, fsdata and xydata objects 0087 y = interp1(x,y,vertices, method, 'extrap'); 0088 else 0089 % for cdata object 0090 y = interp1(y,vertices, method, 'extrap'); 0091 end 0092 0093 %---------------------------- 0094 % Make output AO/cdata 0095 d = a.data; 0096 0097 d = set_xy_axis(d, vertices, y.'); 0098 0099 d = set(d, 'name', sprintf('%s(%s)', method, d.name)); 0100 0101 h = history(ALGONAME, VERSION, pl, a.hist); 0102 h = set(h, 'invars', invars(j)); 0103 0104 % make output analysis object 0105 b = ao(d, h); 0106 0107 % set name 0108 b = setnh(b, 'name', sprintf('%s(%s)', method, invars{j})); 0109 0110 % add to outputs 0111 bs = [bs b]; 0112 0113 end 0114 0115 % Reshape the ouput to the same size of the input 0116 bs = reshape(bs, size(as)); 0117 0118 % Set outputs 0119 varargout{1} = bs; 0120 0121 %-------------------------------------------------------------------------- 0122 % Get default params 0123 function plo = getDefaultPL() 0124 0125 plo = plist(); 0126 plo = append(plo, param('vertices', [])); 0127 plo = append(plo, param('method', 'spline')); 0128 0129 0130 0131 0132 0133 % END