Home > classes > @ao > diag.m

diag

PURPOSE ^

DIAG overloads the diagonal operator for Analysis Objects.

SYNOPSIS ^

function bs = diag(varargin)

DESCRIPTION ^

 DIAG overloads the diagonal operator for Analysis Objects.

 >>  b = diag (a,pl)
 >>  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
 A Monsky 08-05-07

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function bs = diag(varargin)
0002 
0003 % DIAG overloads the diagonal operator for Analysis Objects.
0004 %
0005 % >>  b = diag (a,pl)
0006 % >>  b = diag (a)
0007 %
0008 % Inputs:
0009 %   pl   - a parameter list
0010 %   a    - input analysis object
0011 %
0012 % Outputs:
0013 %   like matlab fct
0014 %
0015 % Parameters:
0016 %  'option' - a string or value that can be submited
0017 % - options are the same as for the matlab function
0018 % A Monsky 08-05-07
0019 %
0020 
0021 % capture input variable names
0022 invars = {};
0023 for j=1:nargin
0024   invars = [invars cellstr(inputname(j))];
0025 end
0026 
0027 ALGONAME = mfilename;
0028 VERSION  = '$Id: diag.html,v 1.1 2007/06/08 14:15:02 hewitson Exp $';
0029 
0030 as = [];
0031 ps = [];
0032 for j=1:nargin
0033     a = varargin{j};
0034     if isa(a, 'ao')
0035         as = [as a];
0036     elseif isa(a, 'plist')
0037         ps = [ps a];
0038 %     else
0039 %         option = [option a];
0040     end
0041     
0042 end
0043 
0044 %handle plist
0045 if ~isempty(ps)
0046     if isa(ps, 'plist')
0047         pl = combine(ps);
0048     end
0049 else
0050     pl = plist();
0051 end
0052 bs = [];
0053 % go through analysis objects
0054 for j=1:length(as)  
0055   a = as(j);
0056 
0057   d = get(a, 'data');
0058   dinfo = whos('d');
0059 
0060   % Which data type do we have
0061   dtype = dinfo.class;
0062   switch dtype
0063 
0064     case 'cdata'
0065       disp('* DIAGONAL of cdata object');
0066        % make a new cdata object
0067       [h, c] = single_operation(d, 'diag',pl);
0068       
0069       % make output analysis object
0070       h = set(h, 'invars', [a.hist]);
0071       b = ao(c, h);
0072       b = set(b, 'name',  sprintf('diag(%s)', char(invars{1})));
0073     case 'tsdata' & 'fsdata' &  'xydata'
0074      error('### this function works for cdata type AO only')
0075     otherwise
0076      error('### unknown data type.')
0077    end
0078 
0079    % add to output
0080    bs = [bs b];  
0081 end
0082 
0083 
0084 % END

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