Home > classes > @ao > diag.m

diag

PURPOSE ^

DIAG overloads the diagonal operator for Analysis Objects.

SYNOPSIS ^

function varargout = diag(varargin)

DESCRIPTION ^

 DIAG overloads the diagonal operator for Analysis Objects.

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

 DESCRIPTION: DIAG overloads the diagonal operator for Analysis Objects.

 CALL:        b = diag (a,pl)    % only with data = cdata
              b = diag (a)

 INPUTS:      pl   - a parameter list
              a    - input analysis object

 OUTPUTS:     like matlab fct

 Parameters:  'option' - a string or value that can be submited
                       - options are the same as for the matlab function

 VERSION:     $Id: diag.m,v 1.9 2007/07/12 15:56:44 ingo Exp $

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

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

 HISTORY: 08-05-07 A Monsky
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = diag(varargin)
0002 % DIAG overloads the diagonal operator for Analysis Objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: DIAG overloads the diagonal operator for Analysis Objects.
0007 %
0008 % CALL:        b = diag (a,pl)    % only with data = cdata
0009 %              b = diag (a)
0010 %
0011 % INPUTS:      pl   - a parameter list
0012 %              a    - input analysis object
0013 %
0014 % OUTPUTS:     like matlab fct
0015 %
0016 % Parameters:  'option' - a string or value that can be submited
0017 %                       - options are the same as for the matlab function
0018 %
0019 % VERSION:     $Id: diag.m,v 1.9 2007/07/12 15:56:44 ingo Exp $
0020 %
0021 % The following call returns a parameter list object that contains the
0022 % default parameter values:
0023 %
0024 % >> pl = diag(ao, 'Params')
0025 %
0026 % HISTORY: 08-05-07 A Monsky
0027 %             Creation
0028 %
0029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0030 
0031 %% Check if this is a call for parameters
0032 
0033 if nargin == 2
0034   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0035     in = char(varargin{2});
0036     if strcmp(in, 'Params')
0037       varargout{1} = getDefaultPL();
0038       return
0039     end
0040   end
0041 end
0042 
0043 %% capture input variable names
0044 invars = {};
0045 
0046 as = [];
0047 bs = [];
0048 pl = [];
0049 
0050 for j=1:nargin
0051   invars = [invars cellstr(inputname(j))];
0052   if isa(varargin{j}, 'ao')
0053     as = [as varargin{j}];
0054   end
0055   if isa(varargin{j}, 'plist')
0056     pl = [pl varargin{j}];
0057   end
0058 end
0059 
0060 
0061 ALGONAME = mfilename;
0062 VERSION  = '$Id: diag.m,v 1.9 2007/07/12 15:56:44 ingo Exp $';
0063 
0064 
0065 if ~isempty (pl)
0066   pl = combine(pl);
0067 end
0068 
0069 
0070 %% go through analysis objects
0071 for j=1:length(as)
0072   a = as(j);
0073 
0074   d = get(a, 'data');
0075   dinfo = whos('d');
0076 
0077   % Which data type do we have
0078   dtype = dinfo.class;
0079   switch dtype
0080 
0081     case 'cdata'
0082       disp('* DIAGONAL of cdata object');
0083        % make a new cdata object
0084       [h, c] = single_operation(d, 'diag',pl);
0085 
0086       % make output analysis object
0087       h = set(h, 'invars', [a.hist]);
0088       b = ao(c, h);
0089       b = set(b, 'name',  sprintf('diag(%s)', char(invars{1})));
0090     case {'tsdata','fsdata','xydata'}
0091      error('### this function works for cdata type AO only')
0092     otherwise
0093      error('### unknown data type.')
0094    end
0095 
0096    % add to output
0097    bs = [bs b];
0098 end
0099 varargout{1} = bs;
0100 
0101 %% Get default params
0102 function plo = getDefaultPL()
0103 
0104 disp('* creating default plist...');
0105 plo = plist();
0106 plo = append(plo, 'option', 0);
0107 disp('* done.');
0108 
0109 % END

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003