


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.html,v 1.2 2007/07/10 05:37:08 hewitson 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


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.html,v 1.2 2007/07/10 05:37:08 hewitson 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 ps = []; 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 ps = [ps varargin{j}]; 0057 end 0058 end 0059 0060 0061 ALGONAME = mfilename; 0062 VERSION = '$Id: diag.html,v 1.2 2007/07/10 05:37:08 hewitson Exp $'; 0063 0064 0065 % check plist 0066 if isempty(ps) 0067 pl = getDefaultPL(); 0068 else 0069 pl = combine(ps, getDefaultPL); 0070 end 0071 0072 %% go through analysis objects 0073 for j=1:nargin 0074 a = varargin{j}; 0075 if isa(a, 'ao') 0076 as = [as a]; 0077 elseif isa(a, 'plist') 0078 ps = [ps a]; 0079 end 0080 0081 end 0082 0083 % check plist 0084 if isempty(ps) 0085 pl = getDefaultPL(); 0086 else 0087 pl = combine(ps, getDefaultPL); 0088 end 0089 0090 %% go through analysis objects 0091 for j=1:length(as) 0092 a = as(j); 0093 0094 d = get(a, 'data'); 0095 dinfo = whos('d'); 0096 0097 % Which data type do we have 0098 dtype = dinfo.class; 0099 switch dtype 0100 0101 case 'cdata' 0102 disp('* DIAGONAL of cdata object'); 0103 % make a new cdata object 0104 [h, c] = single_operation(d, 'diag',pl); 0105 0106 % make output analysis object 0107 h = set(h, 'invars', [a.hist]); 0108 b = ao(c, h); 0109 b = set(b, 'name', sprintf('diag(%s)', char(invars{1}))); 0110 case {'tsdata','fsdata','xydata'} 0111 error('### this function works for cdata type AO only') 0112 otherwise 0113 error('### unknown data type.') 0114 end 0115 0116 % add to output 0117 bs = [bs b]; 0118 end 0119 varargout{1} = bs; 0120 0121 %% Get default params 0122 function plo = getDefaultPL() 0123 0124 disp('* creating default plist...'); 0125 plo = plist(); 0126 disp('* done.'); 0127 0128 % END