INV overloads the inverse function for Analysis Objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: INV overloads the inverse function for Analysis Objects. CALL: a = inv(a1) % only with data = cdata VERSION: $Id: inv.m,v 1.16 2008/02/12 19:29:33 hewitson Exp $ The following call returns a parameter list object that contains the default parameter values: >> pl = inv(ao, 'Params') The following call returns a string that contains the routine CVS version: >> version = inv(ao,'Version') The following call returns a string that contains the routine category: >> category = inv(ao,'Category') HISTORY: 08-05-07 A Monsky Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function varargout = inv(varargin) 0002 % INV overloads the inverse function for Analysis Objects. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: INV overloads the inverse function for Analysis Objects. 0007 % 0008 % CALL: a = inv(a1) % only with data = cdata 0009 % 0010 % VERSION: $Id: inv.m,v 1.16 2008/02/12 19:29:33 hewitson Exp $ 0011 % 0012 % The following call returns a parameter list object that contains the 0013 % default parameter values: 0014 % 0015 % >> pl = inv(ao, 'Params') 0016 % 0017 % The following call returns a string that contains the routine CVS version: 0018 % 0019 % >> version = inv(ao,'Version') 0020 % 0021 % The following call returns a string that contains the routine category: 0022 % 0023 % >> category = inv(ao,'Category') 0024 % 0025 % HISTORY: 08-05-07 A Monsky 0026 % Creation 0027 % 0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0029 0030 VERSION = '$Id: inv.m,v 1.16 2008/02/12 19:29:33 hewitson Exp $'; 0031 CATEGORY = 'Operator'; 0032 0033 bs = []; 0034 0035 %% Check if this is a call for parameters 0036 0037 if nargin == 2 0038 if isa(varargin{1}, 'ao') && ischar(varargin{2}) 0039 in = char(varargin{2}); 0040 if strcmp(in, 'Params') 0041 varargout{1} = getDefaultPL(); 0042 return 0043 elseif strcmp(in, 'Version') 0044 varargout{1} = VERSION; 0045 return 0046 elseif strcmp(in, 'Category') 0047 varargout{1} = CATEGORY; 0048 return 0049 end 0050 end 0051 end 0052 0053 % Collect input ao's, plist's and ao variable names 0054 in_names = {}; 0055 for ii = 1:nargin 0056 in_names{end+1} = inputname(ii); 0057 end 0058 0059 [as, ps, invars] = collect_inputs(varargin, in_names); 0060 0061 % check plist 0062 if isempty(ps) 0063 pl = getDefaultPL(); 0064 else 0065 pl = combine(ps, getDefaultPL); 0066 end 0067 0068 %% go through analysis objects 0069 for j=1:numel(as) 0070 a = as(j); 0071 d = get(a, 'data'); 0072 dinfo = whos('d'); 0073 0074 % Which data type do we have 0075 dtype = dinfo.class; 0076 switch dtype 0077 case 'cdata' 0078 if size(d.y,1) ~= size(d.y,2) 0079 error('### The value (y) of data must be a square matrix.') 0080 else 0081 %disp('* INVERSE of cdata object'); 0082 0083 % make a new cdata object 0084 [h, c] = single_operation(d, 'inv', pl); 0085 0086 % make output analysis object 0087 h = set(h, 'inhists', [a.hist]); 0088 0089 %% Set the var_name to the history 0090 h = set(h, 'invars', cellstr(invars{j})); 0091 0092 b = ao(c, h); 0093 b = setnh(b, 'name', sprintf('inv(%s)', char(invars{j}))); 0094 end 0095 0096 case {'tsdata','fsdata','xydata'} 0097 error('### this function works for cdata type AO only') 0098 otherwise 0099 error('### unknown data type.') 0100 0101 end 0102 0103 % add to output 0104 bs = [bs b]; 0105 end 0106 0107 % Reshape the ouput to the same size of the input 0108 bs = reshape(bs, size(as)); 0109 varargout{1} = bs; 0110 0111 %% Get default params 0112 function plo = getDefaultPL() 0113 0114 plo = plist(); 0115 0116 % END