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

 HISTORY: 23-05-2007 Diepholz
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

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 % HISTORY: 23-05-2007 Diepholz
0029 %             Creation
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 ALGONAME = mfilename;
0034 VERSION  = '$Id: std.html,v 1.1 2007/06/08 14:15:03 hewitson Exp $';
0035 ao_out   = [];
0036 pl       = plist();
0037 option   = '';
0038 
0039 %% store the input ao's in the vector: ao_set
0040 ao_set = [];
0041 for i=1:nargin
0042   a = varargin{i};
0043   if isa(a, 'ao')
0044     [m,n] = size(a);
0045     for i = 1:m
0046       for j = 1:n
0047         ao_set  = [ao_set a(i,j)];
0048       end
0049     end
0050   elseif isa(varargin{i}, 'plist')
0051     pl = [pl varargin{i}];
0052   elseif isnumeric(varargin{i})
0053     pl = [pl plist(param('dim', varargin{i}))];
0054   end
0055 end
0056 
0057 if ~isempty (pl)
0058   pl = combine(pl);
0059 end
0060 
0061 %% go through analysis objects
0062 for j=1:length(ao_set)
0063   a = ao_set(j);
0064 
0065   [h, std_data] = single_operation(a.data, 'std', pl);
0066 
0067   %% Add the history from the ao object to the history
0068   h = set(h, 'inhists', [a.hist]);
0069 
0070   %% Set the var_name to the history
0071   if (j <= nargin)
0072     if (isempty (inputname(j)))
0073       h = set(h, 'invars', cellstr('no var_name'));
0074     else
0075       h = set(h, 'invars', cellstr(inputname(j)));
0076     end
0077   else
0078     h = set(h, 'invars', cellstr('no var_name'));
0079   end
0080 
0081   % convert to cdata type
0082   std_x    = [];
0083   std_y    = [];
0084 
0085   do_xdata = find(pl, 'xdata');
0086   do_ydata = find(pl, 'ydata');
0087 
0088   %% Is no axis entry in the parameter list
0089   %% then set the default axis = xdata
0090   if isempty(do_xdata) && isempty(do_ydata)
0091     do_ydata = 'yes';
0092   end
0093 
0094   %% Get the operation result. It is stored in the individual axis
0095   pl_get_axis = plist([param('xdata', do_xdata) param('ydata', do_ydata)]);
0096   [std_x, std_y] = get_xy_axis(std_data, pl_get_axis);
0097 
0098   std_cdata = cdata([std_x std_y]);
0099   std_cdata = set (std_cdata, 'name', std_data.name);
0100   std_cdata = set (std_cdata, 'xunits', std_data.xunits);
0101   std_cdata = set (std_cdata, 'yunits', std_data.yunits);
0102 
0103   %% create a new analysis objects
0104   new_ao = a;
0105   new_ao = ao  (std_cdata, h);
0106   new_ao = set (new_ao, 'name', sprintf('std(%s)',a.name) );
0107 
0108   ao_out = [ao_out new_ao];
0109 
0110 end
0111 
0112 % END

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003