


ltpda_ss_check throws an error is something is wrong is found in the subsystem.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: ltpda_ss_check checks the fields of a susbsystem.
CALL: testSys(syst)
INPUTS: a - subsystem dscribed by a plist
syst = plist('TYPE', TYPE ,'NAME', NAME ,'TIMESTEP', TIMESTEP ,...
'PARAMNAMES', PARAMNAMES ,'PARAMVALUES', PARAMVALUES ,'PARAMSIGMAS', PARAMSIGMAS ,...
'NBINPUTS', NBINPUTS ,'INPUTNAMES', INPUTNAMES ,'INPUTSIZES', INPUTSIZES ,'INPUTISUSED', INPUTISUSED ,...
'AMAT', AMAT ,'BMATS', BMATS ,'CMAT', CMAT ,'DMATS', DMATS );
OUTPUTS: binary : 1 (ok) 0 (pb) (also throws an error if there is a problem)
PARAMETERS:
'TYPE' should be 'SUBSYSTEM'
'NAME' is a string
'TIMESTEP' is a real positive integer, set to zero in continuous case
'PARAMNAMES' cell array of strings describing parameter variables
'PARAMVALUES' array of doubles (means expected of parameters)
'PARAMSIGMAS' array of doubles (variance expected of parameters)
'NBINPUTS' integer number of inputs
'INPUTNAMES' cell array of strings (name of the inputs)
'INPUTSIZES'array of integers (nb of dimensions of the inputs),
'INPUTISUSED' double array (binary to indicate which inputs are used)
'AMAT' cell array (contains A matrix)
'BMATS' cell array (contains B matrices)
'CMAT' cell array (contains C matrix)
'DMATS' cell array (contains D matrices)
***** THERE ARE NO DEFAULT PARAMETERS *****
VERSION: $Id: ltpda_ss_check.m,v 1.3 2008/02/25 12:43:44 adrien Exp $
HISTORY: 21-01-2008 A Grynagier
Creation 05-01-2008 A Grynagier
TO DO : Nothing for now.
Add checks for the derviative fields later and think on how to handle the
linear derivative case
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% standard calls for LTPDA function data

0001 function varargout = ltpda_ss_check(varargin) 0002 % ltpda_ss_check throws an error is something is wrong is found in the subsystem. 0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0004 % 0005 % DESCRIPTION: ltpda_ss_check checks the fields of a susbsystem. 0006 % 0007 % CALL: testSys(syst) 0008 % 0009 % INPUTS: a - subsystem dscribed by a plist 0010 % syst = plist('TYPE', TYPE ,'NAME', NAME ,'TIMESTEP', TIMESTEP ,... 0011 % 'PARAMNAMES', PARAMNAMES ,'PARAMVALUES', PARAMVALUES ,'PARAMSIGMAS', PARAMSIGMAS ,... 0012 % 'NBINPUTS', NBINPUTS ,'INPUTNAMES', INPUTNAMES ,'INPUTSIZES', INPUTSIZES ,'INPUTISUSED', INPUTISUSED ,... 0013 % 'AMAT', AMAT ,'BMATS', BMATS ,'CMAT', CMAT ,'DMATS', DMATS ); 0014 % 0015 % OUTPUTS: binary : 1 (ok) 0 (pb) (also throws an error if there is a problem) 0016 % 0017 % PARAMETERS: 0018 % 'TYPE' should be 'SUBSYSTEM' 0019 % 'NAME' is a string 0020 % 'TIMESTEP' is a real positive integer, set to zero in continuous case 0021 % 'PARAMNAMES' cell array of strings describing parameter variables 0022 % 'PARAMVALUES' array of doubles (means expected of parameters) 0023 % 'PARAMSIGMAS' array of doubles (variance expected of parameters) 0024 % 'NBINPUTS' integer number of inputs 0025 % 'INPUTNAMES' cell array of strings (name of the inputs) 0026 % 'INPUTSIZES'array of integers (nb of dimensions of the inputs), 0027 % 'INPUTISUSED' double array (binary to indicate which inputs are used) 0028 % 'AMAT' cell array (contains A matrix) 0029 % 'BMATS' cell array (contains B matrices) 0030 % 'CMAT' cell array (contains C matrix) 0031 % 'DMATS' cell array (contains D matrices) 0032 % ***** THERE ARE NO DEFAULT PARAMETERS ***** 0033 % 0034 % VERSION: $Id: ltpda_ss_check.m,v 1.3 2008/02/25 12:43:44 adrien Exp $ 0035 % 0036 % HISTORY: 21-01-2008 A Grynagier 0037 % Creation 05-01-2008 A Grynagier 0038 % 0039 % TO DO : Nothing for now. 0040 % Add checks for the derviative fields later and think on how to handle the 0041 % linear derivative case 0042 % 0043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0044 %% standard calls for LTPDA function data 0045 0046 ALGONAME = mfilename; 0047 VERSION = '$Id: ltpda_ss_check.m,v 1.3 2008/02/25 12:43:44 adrien Exp $'; 0048 CATEGORY = 'STATESPACE'; 0049 display(['starting ' ALGONAME]); 0050 0051 if isequal( varargin{1}, 'Version') 0052 varargout = VERSION; 0053 return; 0054 elseif isequal(varargin{1}, 'Params') 0055 varargout = plist(); 0056 return; 0057 elseif isequal(varargin{1}, 'Category') 0058 varargout = CATEGORY; 0059 return; 0060 end 0061 0062 syst = varargin{1}; 0063 0064 %% proceeding checks 0065 varargout = 1; 0066 try 0067 % check type is a system 0068 if not( isequal(syst.params(1).val,'SUBSYSTEM') ) 0069 msg = [ 'Error in SubSystem ', find(syst,'NAME') , ' , TYPE is not defined as a subsystem']; 0070 error(msg); 0071 end 0072 0073 % system has a name 0074 if isequal(find(syst,'NAME') , '') 0075 msg = 'error because subsystem has no name!'; 0076 error(msg); 0077 end 0078 0079 % meaningful timestep 0080 if find(syst,'TIMESTEP')<0 0081 msg = [ 'error in SubSystem ', find(syst,'NAME') , ' because negative timestep']; 0082 error(msg); 0083 end 0084 0085 % check length of parameter data fields 0086 L4=length(find(syst,'PARAMNAMES')); 0087 L5=length(find(syst,'PARAMVALUES')); 0088 L6=length(find(syst,'PARAMSIGMAS')); 0089 if not( isequal(L4,L5,L6) ) 0090 msg = [ 'error in SubSystem ', find(syst,'NAME') , ', incoherent number of parameters/means/sigmas : ', num2str(L4), ',' , num2str(L5), ',' , num2str(L6) ]; 0091 error(msg); 0092 end 0093 % should check that the same parameter is not defined twice!!! 0094 0095 % test on the number of intputs 0096 L7=find(syst,'NBINPUTS') ; 0097 L8=length( find(syst,'INPUTNAMES') ); 0098 L9=length( find(syst,'INPUTSIZES') ); 0099 L10=length( find(syst,'INPUTISUSED') ); 0100 L12=length( find(syst,'BMATS') ); 0101 L14=length( find(syst,'DMATS') ); 0102 if not( isequal(L7,L8,L9,L10,L12,L14) ) 0103 msg = [ 'error in SubSystem ', find(syst,'NAME') , ' incoherent number of inputs/names/sizes/used/Bmats/Dmats: ', num2str(L7), ',' , num2str(L8), ',' , num2str(L9), ',' , num2str(L10), ',' , num2str(L12), ',' , num2str(L14) ]; 0104 error(msg); 0105 end 0106 0107 % test on the size of intput matrices 0108 % and fitting to state space and output size 0109 AMAT = find(syst,'AMAT'); 0110 CMAT = find(syst,'CMAT'); 0111 SSsize = size(AMAT{1},1); 0112 OUTsize = size(CMAT{1},1); 0113 INPUTSIZES = find(syst,'IMPUTNAMES'); 0114 BMATS = find(syst,'BMATS'); 0115 DMATS = find(syst,'DMATS'); 0116 INPUTNAMES = find(syst,'INPUTNAMES'); 0117 for i=1:length(INPUTSIZES) 0118 if not( isequal(INPUTSIZES(i),size(BMATS{i},2),size(DMATS{i},2) ) ) 0119 msg = [ 'error in SubSystem ', find(syst,'NAME') , ' for input named ', INPUTNAMES{i} ,' because size of input matrices and declared size do not match altoghether']; 0120 error(msg); 0121 end 0122 if not( isequal(SSsize,size(BMATS{i},1)) ) 0123 msg = [ 'error in SubSystem ', find(syst,'NAME') , ' because wrong size of B matrix (height does not fit to State Space) in input named ', INPUTNAMES{i}]; 0124 error(msg); 0125 end 0126 if not( isequal(OUTsize,size(DMATS{i},1)) ) 0127 msg = [ 'error in SubSystem ', find(syst,'NAME') , ' because wrong size of D matrix (height does not fit to Output) in input named ', INPUTNAMES{i}]; 0128 error(msg); 0129 end 0130 end 0131 0132 % test on A and C 0133 if not( isequal(SSsize, size(AMAT{1},2), size(CMAT{1},2)) ) 0134 msg= [ 'error in SubSystem ', find(syst,'NAME') , ' either because A is not square or C does not fit to A']; 0135 error(msg); 0136 end 0137 catch 0138 varargout =0; 0139 end 0140 0141 end