Home > classes > @ao > std.m

std

PURPOSE ^

STD overloads the std operator for Analysis objects. Compute the standard deviation.

SYNOPSIS ^

function ao_out = std (varargin)

DESCRIPTION ^

 STD overloads the std operator for Analysis objects. Compute the standard deviation.

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

 DESCRIPTION: STD overloads the std operator for Analysis objects.
              Compute the standard deviation.
              STD(ao) is the standard deviation value of the elements in ao.data.

 CALL: ao_out = std(ao_in);
       ao_out = std(ao_in, dim);
       ao_out = std(ao_in, FLAG, DIM); --> use the parameterlist
       ao_out = std(ao_in, pl);
       ao_out = std(ao1, pl1, ao_vector, ao_matrix, pl2);

 POSSIBLE VALUES: ao_in  = [ao2 ao3]
                  ao_in  = ao_vector
                  ao_in  = ao_matrix

 PARAMETER LIST:  <key>           <value>             <description>
                   'W'             0 of 1           represent the FLAG
                  'dim'          1 or 2 or 3 ...    takes the std along the
                                                    dimension dim
                          tsdata  fsdata  xydata
                 'xdata'   't'     'f'      'x'     compute the std of the x-axis
                 'ydata'   'x'     'xx'     'y'     compute the std of the y-axis

 The following call returns a parameter list object that contains the
 default parameter values:

 >> pl = std(ao, 'Params')

 The following call returns a string that contains the routine CVS version:

 >> version = std(ao,'Version')

 The following call returns a string that contains the routine category:

 >> category = std(ao,'Category')

 HISTORY: 23-05-2007 Diepholz
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function ao_out = std (varargin)
0002 % STD overloads the std operator for Analysis objects. Compute the standard deviation.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: STD overloads the std operator for Analysis objects.
0007 %              Compute the standard deviation.
0008 %              STD(ao) is the standard deviation value of the elements in ao.data.
0009 %
0010 % CALL: ao_out = std(ao_in);
0011 %       ao_out = std(ao_in, dim);
0012 %       ao_out = std(ao_in, FLAG, DIM); --> use the parameterlist
0013 %       ao_out = std(ao_in, pl);
0014 %       ao_out = std(ao1, pl1, ao_vector, ao_matrix, pl2);
0015 %
0016 % POSSIBLE VALUES: ao_in  = [ao2 ao3]
0017 %                  ao_in  = ao_vector
0018 %                  ao_in  = ao_matrix
0019 %
0020 % PARAMETER LIST:  <key>           <value>             <description>
0021 %                   'W'             0 of 1           represent the FLAG
0022 %                  'dim'          1 or 2 or 3 ...    takes the std along the
0023 %                                                    dimension dim
0024 %                          tsdata  fsdata  xydata
0025 %                 'xdata'   't'     'f'      'x'     compute the std of the x-axis
0026 %                 'ydata'   'x'     'xx'     'y'     compute the std of the y-axis
0027 %
0028 % The following call returns a parameter list object that contains the
0029 % default parameter values:
0030 %
0031 % >> pl = std(ao, 'Params')
0032 %
0033 % The following call returns a string that contains the routine CVS version:
0034 %
0035 % >> version = std(ao,'Version')
0036 %
0037 % The following call returns a string that contains the routine category:
0038 %
0039 % >> category = std(ao,'Category')
0040 %
0041 % HISTORY: 23-05-2007 Diepholz
0042 %             Creation
0043 %
0044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0045 
0046 VERSION = '$Id: std.html,v 1.14 2008/03/31 10:27:33 hewitson Exp $';
0047 CATEGORY = 'Operator';
0048 
0049 ao_out  = [];
0050 
0051 %% Check if this is a call for parameters
0052 if nargin == 2
0053   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0054     in = char(varargin{2});
0055     if strcmp(in, 'Params')
0056       ao_out = getDefaultPL();
0057       return
0058     elseif strcmp(in, 'Version')
0059       ao_out = VERSION;
0060       return
0061     elseif strcmp(in, 'Category')
0062       ao_out = CATEGORY;
0063       return
0064     end
0065   end
0066 end
0067 
0068 %% Collect input ao's, plist's and ao variable names
0069 in_names = {};
0070 ps       = plist();
0071 for ii = 1:nargin
0072   in_names{end+1} = inputname(ii);
0073 
0074   if isnumeric(varargin{ii})
0075     ps = [ps plist(param('dim', varargin{ii}))];
0076   end
0077 end
0078 
0079 [ao_set, pl, invars] = collect_inputs(varargin, in_names);
0080 
0081 pl = combine(pl, ps);
0082 
0083 %% go through analysis objects
0084 for j=1:numel(ao_set)
0085   a = ao_set(j);
0086 
0087   [h, std_data] = single_operation(a.data, 'std', pl);
0088 
0089   %% Add the history from the ao object to the history
0090   h = set(h, 'inhists', [a.hist]);
0091 
0092   %% Set the var_name to the history
0093   h = set(h, 'invars', cellstr(invars{j}));
0094 
0095   % convert to cdata type
0096   std_x    = [];
0097   std_y    = [];
0098 
0099   do_xdata = find(pl, 'xdata');
0100   do_ydata = find(pl, 'ydata');
0101 
0102   %% Is no axis entry in the parameter list
0103   %% then set the default axis = xdata
0104   if isempty(do_xdata) && isempty(do_ydata)
0105     do_ydata = 'yes';
0106   end
0107 
0108   %% Get the operation result. It is stored in the individual axis
0109   pl_get_axis = plist([param('xdata', do_xdata) param('ydata', do_ydata)]);
0110   [std_x, std_y] = get_xy_values(std_data, pl_get_axis);
0111 
0112   if ~isempty(do_xdata) && ~isempty(do_ydata)
0113     std_cdata = cdata([std_x std_y]);
0114   elseif ~isempty(do_xdata)
0115     std_cdata = cdata(std_x);
0116   else
0117     std_cdata = cdata(std_y);
0118   end
0119 
0120   std_cdata = set (std_cdata, 'name', std_data.name);
0121   std_cdata = set (std_cdata, 'xunits', std_data.xunits);
0122   std_cdata = set (std_cdata, 'yunits', std_data.yunits);
0123 
0124   %% create a new analysis objects
0125   new_ao = ao  (std_cdata, h);
0126   new_ao = setnh(new_ao, 'name', sprintf('std(%s)',invars{j}) );
0127 
0128   ao_out = [ao_out new_ao];
0129 
0130 end
0131 
0132 % Reshape the ouput to the same size of the input
0133 ao_out = reshape(ao_out, size(ao_set));
0134 
0135 %% Get default params
0136 function pl_default = getDefaultPL()
0137 
0138   pl_default = plist([param('dim',    '')
0139                       param('W',      [])
0140                       param('xdata',  '')
0141                       param('ydata',  '')]);
0142 
0143 % END

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003