ltpda_miir2ss converts a iir filter model into a subsystem. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: ltpda_miir2ss converts a iir filter model into a subsystem. Right now the new state space is written in the cannonincal controllable form, and has - of course - only one input. For intellignent conversion to state space models, it is advised to make use of pzm2ss which computes the state space in the jordan form of A. A version calling for use of 'residue' function was not used due to numerical error concerns. CALL: subsys = ltpda_miir2ss(iir) INPUTS: iir - an infinite inpulsr response model object OUTPUTS: subsys - subsystem dscribed by a plist subsystem plist format (More updated infos might be available in the ltpda_ss_check function): 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 );% 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_iir2ss.html,v 1.4 2008/03/31 10:27:36 hewitson Exp $ HISTORY: 26-02-2008 A Grynagier 8-02-2008 A Grynagier 7-02-2008 A Grynagier 2-02-2008 A Grynagier TO DO : possibly add the jordan block option %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function varargout = ltpda_ss_iir2ss(varargin) 0002 % ltpda_miir2ss converts a iir filter model into a subsystem. 0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0004 % 0005 % DESCRIPTION: ltpda_miir2ss converts a iir filter model into a subsystem. 0006 % Right now the new state space is written in the cannonincal controllable 0007 % form, and has - of course - only one input. 0008 % For intellignent conversion to state space models, it is advised to 0009 % make use of pzm2ss which computes the state space in the jordan form of 0010 % A. 0011 % A version calling for use of 'residue' function was not used due to 0012 % numerical error concerns. 0013 % 0014 % CALL: subsys = ltpda_miir2ss(iir) 0015 % 0016 % INPUTS: iir - an infinite inpulsr response model object 0017 % 0018 % OUTPUTS: subsys - subsystem dscribed by a plist 0019 % 0020 % subsystem plist format (More updated infos might be available in the 0021 % ltpda_ss_check function): 0022 % plist('TYPE', TYPE ,'NAME', NAME ,'TIMESTEP', TIMESTEP ,... 0023 % 'PARAMNAMES', PARAMNAMES ,'PARAMVALUES', PARAMVALUES ,'PARAMSIGMAS', PARAMSIGMAS ,... 0024 % 'NBINPUTS', NBINPUTS ,'INPUTNAMES', INPUTNAMES ,'INPUTSIZES', INPUTSIZES ,'INPUTISUSED', INPUTISUSED ,... 0025 % 'AMAT', AMAT ,'BMATS', BMATS ,'CMAT', CMAT ,'DMATS', DMATS );% PARAMETERS: 0026 % 'TYPE' should be 'SUBSYSTEM' 0027 % 'NAME' is a string 0028 % 'TIMESTEP' is a real positive integer, set to zero in continuous case 0029 % 'PARAMNAMES' cell array of strings describing parameter variables 0030 % 'PARAMVALUES' array of doubles (means expected of parameters) 0031 % 'PARAMSIGMAS' array of doubles (variance expected of parameters) 0032 % 'NBINPUTS' integer number of inputs 0033 % 'INPUTNAMES' cell array of strings (name of the inputs) 0034 % 'INPUTSIZES'array of integers (nb of dimensions of the inputs), 0035 % 'INPUTISUSED' double array (binary to indicate which inputs are used) 0036 % 'AMAT' cell array (contains A matrix) 0037 % 'BMATS' cell array (contains B matrices) 0038 % 'CMAT' cell array (contains C matrix) 0039 % 'DMATS' cell array (contains D matrices) 0040 % ***** THERE ARE NO DEFAULT PARAMETERS ***** 0041 % 0042 % VERSION: $Id: ltpda_ss_iir2ss.html,v 1.4 2008/03/31 10:27:36 hewitson Exp $ 0043 % 0044 % HISTORY: 26-02-2008 A Grynagier 0045 % 8-02-2008 A Grynagier 0046 % 7-02-2008 A Grynagier 0047 % 2-02-2008 A Grynagier 0048 % 0049 % TO DO : possibly add the jordan block option 0050 % 0051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0052 0053 ALGONAME = mfilename; 0054 VERSION = '$Id: ltpda_ss_iir2ss.html,v 1.4 2008/03/31 10:27:36 hewitson Exp $'; 0055 CATEGORY = 'STATESPACE'; 0056 display(['starting ' ALGONAME]); 0057 0058 if not(isempty(varargin)) 0059 if isequal( varargin{1}, 'Version') 0060 varargout = VERSION; 0061 return; 0062 elseif isequal(varargin{1}, 'Params') 0063 varargout = plist(); 0064 return; 0065 elseif isequal(varargin{1}, 'Category') 0066 varargout = CATEGORY; 0067 return; 0068 end 0069 else 0070 error('not enough input arguments'); 0071 end 0072 0073 iirs = varargin{1}; 0074 syst = plist(); 0075 for i =1:length(iirs) 0076 iir =iirs(i); 0077 0078 a = iir.a; 0079 b = iir.b; 0080 0081 % for next part check must be made there is no pole zero cancelation 0082 nss = size(b,2)-1; 0083 0084 % is residue ok?? 0085 [r,p,k] = residue(a,b); %!! here b are for the poles, a the zeros 0086 D = k; 0087 0088 a = a/b(1); 0089 b = b/b(1); 0090 0091 0092 A = [zeros(nss-1,1) eye(nss-1); b(2:length(b))]; 0093 B = [zeros(nss-1,1) ;1]; 0094 C = a; 0095 0096 0097 syst_loc = plist('TYPE', 'SUMBSYSTEM' ,'NAME', iir.name ,'TIMESTEP', 1/(iir.fs), ... 0098 'XISOUTPUT', 0,'YISOUTPUT',1,'XINI', zeros(nss,1) , ... 0099 'PARAMNAMES', {},'PARAMVALUES', [],'PARAMSIGMAS', [],... 0100 'NBINPUTS', iir.ntaps ,'INPUTNAMES', {'U_1'} ,'INPUTSIZES', 1 , 'INPUTISUSED', 1 ,... 0101 'AMAT', {A} ,'BMATS', {B} ,'CMAT', {C} ,'DMATS', {D} ); 0102 0103 ltpda_ss_check(syst_loc); 0104 syst(i) = syst_loc; 0105 end 0106 varargout = {syst}; 0107 end