Home > classes > @ao > fromVals.m

fromVals

PURPOSE ^

FROMVALS Construct an ao from a value set

SYNOPSIS ^

function a = fromVals(a, pli)

DESCRIPTION ^

 FROMVALS Construct an ao from a value set
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    fromVals

 DESCRIPTION: Construct an ao from a value set

 CALL:        a = aoFromVals(a, vals)

 PARAMETER:
              vals:     Constant values

 HISTORY:     07-05-2007 Hewitson
              Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % FROMVALS Construct an ao from a value set
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % FUNCTION:    fromVals
0005 %
0006 % DESCRIPTION: Construct an ao from a value set
0007 %
0008 % CALL:        a = aoFromVals(a, vals)
0009 %
0010 % PARAMETER:
0011 %              vals:     Constant values
0012 %
0013 % HISTORY:     07-05-2007 Hewitson
0014 %              Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 function a = fromVals(a, pli)
0018 
0019   VERSION = '$Id: fromVals.m,v 1.14 2008/09/04 13:37:14 ingo Exp $';
0020 
0021   % get AO info
0022   ii = ao.getInfo('ao', 'From Vals');
0023 
0024   % Set the method version string in the minfo object
0025   ii.setMversion([VERSION '-->' ii.mversion]);
0026 
0027   % Combine input plist with default values
0028   pl = combine(pli, ii.plists);
0029 
0030   % Get values from the plist
0031   vals  = find(pl, 'vals');
0032   xvals = find(pl, 'xvals');
0033   yvals = find(pl, 'yvals');
0034   N     = find(pl, 'N');
0035 
0036   % If the user specified no repeats, we go for 1 repeat.
0037   if isempty(N)
0038     N = 1;
0039   end
0040 
0041   %--------- Now decide what to construct
0042 
0043   % We have x and y values
0044   if ~isempty(xvals) && ~isempty(yvals)
0045     if ischar(xvals)
0046       try
0047         xvals = eval(xvals);
0048       catch
0049         error('Could not convert char array to numeric array.');
0050       end
0051     end
0052     if ischar(yvals)
0053       try
0054         yvals = eval(yvals);
0055       catch
0056         error('Could not convert char array to numeric array.');
0057       end
0058     end
0059     % Make a tsdata object
0060     ts = tsdata(xvals, yvals);
0061 
0062     % We have only y values
0063   elseif ~isempty(vals)
0064     if ischar(vals)
0065       try
0066         vals = eval(vals);
0067       catch
0068         error('Could not convert char array to numeric array.');
0069       end
0070     end
0071     % Make a cdata object
0072     ts = cdata(repmat(vals, 1, N));
0073 
0074   else
0075     error('### Unknown constructor');
0076   end
0077 
0078   % Set data
0079   a.data  = ts;
0080   % Add history
0081   a.addHistory(ii, pl, [], []);
0082 
0083 end
0084

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003