test conversion from state-space to pole zero model %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: test conversion from state-space to pole zero model CALL: utp_ltpda_ss_pz2ss INPUTS: none OUTPUTS: 1/0 ***** THERE ARE NO DEFAULT PARAMETERS ***** VERSION: $Id: utp_ltpda_ss_pz2ss.m,v 1.4 2008/03/11 16:52:56 adrien Exp $ HISTORY: 22-01-2008 A Grynagier TO DO : syntaxic (and more numerical tests), consider the jordan bloc/partial fraction expansion case for higher precision, or possibly the use of the vpa function. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function varargout = utp_ltpda_ss_pz2ss(varargin) 0002 % test conversion from state-space to pole zero model 0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0004 % 0005 % DESCRIPTION: test conversion from state-space to pole zero model 0006 % 0007 % CALL: utp_ltpda_ss_pz2ss 0008 % 0009 % INPUTS: none 0010 % 0011 % OUTPUTS: 1/0 0012 % 0013 % ***** THERE ARE NO DEFAULT PARAMETERS ***** 0014 % 0015 % VERSION: $Id: utp_ltpda_ss_pz2ss.m,v 1.4 2008/03/11 16:52:56 adrien Exp $ 0016 % 0017 % HISTORY: 22-01-2008 A Grynagier 0018 % 0019 % TO DO : syntaxic (and more numerical tests), consider the jordan bloc/partial 0020 % fraction expansion case for higher precision, or possibly the use of the 0021 % vpa function. 0022 % 0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0024 VERSION = '$Id: utp_ltpda_ss_pz2ss.m,v 1.4 2008/03/11 16:52:56 adrien Exp $'; 0025 ALGONAME = mfilename; 0026 CATEGORY = 'STATESPACE'; 0027 display(['starting ' ALGONAME]); 0028 0029 if not(isempty(varargin)) 0030 if isequal( varargin{1}, 'Version') 0031 varargout = VERSION; 0032 return; 0033 elseif isequal(varargin{1}, 'Params') 0034 varargout = plist(); 0035 return; 0036 elseif isequal(varargin{1}, 'Category') 0037 varargout = CATEGORY; 0038 return; 0039 end 0040 end 0041 result = 1; 0042 % p = pzmodel(1,[pole(1) pole(2,2) pole(3) pole(4)], [zero(5) zero(6) zero(7)]); 0043 try 0044 p = pzmodel(1,pole(2/2/pi,1) , [zero(-1/2/pi) zero(-2/2/pi) ]); 0045 p = [p, p]; 0046 subsys = ltpda_ss_pz2ss(p); 0047 Amat = find(subsys(2), 'AMAT'); 0048 Bmats = find(subsys(2), 'BMATS'); 0049 Cmat = find(subsys(2), 'CMAT'); 0050 Dmats = find(subsys(2), 'DMATS'); 0051 A = Amat{1}; 0052 B = Bmats{1}; 0053 C = Cmat{1}; 0054 D = Dmats{1}; 0055 [a,b] = ss2tf(A,B,C,D); %#ok<NASGU> 0056 if (norm(A-[0 1; 2 3]) + norm(B-[0;1]) + norm(C-[2 -1]) + norm(D-1))>1e-14 0057 result = 0; 0058 end 0059 catch 0060 result = 0; 0061 end 0062 if result ==1 0063 display('ok') 0064 else 0065 display('pb') 0066 end 0067 varargout = {result}; 0068 end