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')

 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 % HISTORY: 23-05-2007 Diepholz
0034 %             Creation
0035 %
0036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0037 
0038 VERSION  = '$Id: std.m,v 1.7 2007/10/24 17:35:28 ingo Exp $';
0039 ao_out   = [];
0040 pl       = plist();
0041 
0042 %% Check if this is a call for parameters
0043 if nargin == 2
0044   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0045     in = char(varargin{2});
0046     if strcmp(in, 'Params')
0047       ao_out = getDefaultPL();
0048       return
0049     elseif strcmp(in, 'Version')
0050       ao_out = VERSION;
0051       return
0052     end
0053   end
0054 end
0055 
0056 %% store the input ao's in the vector: ao_set
0057 ao_set = [];
0058 for i=1:nargin
0059   a = varargin{i};
0060   if isa(a, 'ao')
0061     ao_set  = [ao_set a];
0062   elseif isa(varargin{i}, 'plist')
0063     pl = [pl varargin{i}];
0064   elseif isnumeric(varargin{i})
0065     pl = [pl plist(param('dim', varargin{i}))];
0066   end
0067 end
0068 
0069 if ~isempty (pl)
0070   pl = combine(pl);
0071 end
0072 
0073 %% go through analysis objects
0074 for j=1:numel(ao_set)
0075   a = ao_set(j);
0076 
0077   [h, std_data] = single_operation(a.data, 'std', pl);
0078 
0079   %% Add the history from the ao object to the history
0080   h = set(h, 'inhists', [a.hist]);
0081 
0082   %% Set the var_name to the history
0083   if (j <= nargin)
0084     if (isempty (inputname(j)))
0085       h = set(h, 'invars', cellstr('no var_name'));
0086     else
0087       h = set(h, 'invars', cellstr(inputname(j)));
0088     end
0089   else
0090     h = set(h, 'invars', cellstr('no var_name'));
0091   end
0092 
0093   % convert to cdata type
0094   std_x    = [];
0095   std_y    = [];
0096 
0097   do_xdata = find(pl, 'xdata');
0098   do_ydata = find(pl, 'ydata');
0099 
0100   %% Is no axis entry in the parameter list
0101   %% then set the default axis = xdata
0102   if isempty(do_xdata) && isempty(do_ydata)
0103     do_ydata = 'yes';
0104   end
0105 
0106   %% Get the operation result. It is stored in the individual axis
0107   pl_get_axis = plist([param('xdata', do_xdata) param('ydata', do_ydata)]);
0108   [std_x, std_y] = get_xy_values(std_data, pl_get_axis);
0109 
0110   std_cdata = cdata([std_x std_y]);
0111   std_cdata = set (std_cdata, 'name', std_data.name);
0112   std_cdata = set (std_cdata, 'xunits', std_data.xunits);
0113   std_cdata = set (std_cdata, 'yunits', std_data.yunits);
0114 
0115   %% create a new analysis objects
0116   new_ao = a;
0117   new_ao = ao  (std_cdata, h);
0118   new_ao = set (new_ao, 'name', sprintf('std(%s)',a.name) );
0119 
0120   ao_out = [ao_out new_ao];
0121 
0122 end
0123 
0124 % Reshape the ouput to the same size of the input
0125 ao_out = reshape(ao_out, size(ao_set));
0126 
0127 %% Get default params
0128 function pl_default = getDefaultPL()
0129 
0130   pl_default = plist([param('dim',    '')
0131                       param('W',      [])
0132                       param('xdata',  '')
0133                       param('ydata',  '')]);
0134 
0135 % END

Generated on Thu 01-Nov-2007 09:42:34 by m2html © 2003