0001 function bs = diag(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
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
0039
0040 end
0041
0042 end
0043
0044
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
0054 for j=1:length(as)
0055 a = as(j);
0056
0057 d = get(a, 'data');
0058 dinfo = whos('d');
0059
0060
0061 dtype = dinfo.class;
0062 switch dtype
0063
0064 case 'cdata'
0065 disp('* DIAGONAL of cdata object');
0066
0067 [h, c] = single_operation(d, 'diag',pl);
0068
0069
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
0080 bs = [bs b];
0081 end
0082
0083
0084