comparison scripts/control/system/ss2tf.m @ 7125:f084ba47812b

[project @ 2007-11-08 02:29:23 by jwe]
author jwe
date Thu, 08 Nov 2007 02:29:24 +0000
parents a1dbe9d80eee
children
comparison
equal deleted inserted replaced
7124:d07cb867891b 7125:f084ba47812b
57 ## Created: June 24, 1994 57 ## Created: June 24, 1994
58 ## a s hodel: modified to allow for pure gain blocks Aug 1996 58 ## a s hodel: modified to allow for pure gain blocks Aug 1996
59 59
60 function [num, den] = ss2tf (a, b, c, d) 60 function [num, den] = ss2tf (a, b, c, d)
61 61
62 if (nargin != 4)
63 print_usage ();
64 endif
65
62 ## Check args 66 ## Check args
63 [n,m,p] = abcddim(a,b,c,d); 67 [n, m, p] = abcddim (a, b, c, d);
64 if (n == -1) 68 if (n == -1)
65 num = []; 69 num = [];
66 den = []; 70 den = [];
67 error("ss2tf: Non compatible matrix arguments"); 71 error("ss2tf: Non compatible matrix arguments");
68 elseif ( (m != 1) | (p != 1)) 72 elseif (m != 1 || p != 1)
69 num = []; 73 num = [];
70 den = []; 74 den = [];
71 error(["ss2tf: not SISO system: m=",num2str(m)," p=",num2str(p)]); 75 error ("ss2tf: not SISO system: m=%d, p=%d", m, p);
72 endif 76 endif
73 77
74 if(n == 0) 78 if(n == 0)
75 ## gain block only 79 ## gain block only
76 num = d; 80 num = d;
77 den = 1; 81 den = 1;
78 else 82 else
79 ## First, get the denominator coefficients 83 ## First, get the denominator coefficients
80 den = poly(a); 84 den = poly (a);
81 85
82 ## Get the zeros of the system 86 ## Get the zeros of the system
83 [zz,g] = tzero(a,b,c,d); 87 [zz, g] = tzero (a, b, c, d);
84 88
85 ## Form the Numerator (and include the gain) 89 ## Form the Numerator (and include the gain)
86 if (!isempty(zz)) 90 if (! isempty (zz))
87 num = g * poly(zz); 91 num = g * poly (zz);
88 else 92 else
89 num = g; 93 num = g;
90 endif 94 endif
91 95
92 ## the coefficients must be real 96 ## the coefficients must be real
93 den = real(den); 97 den = real (den);
94 num = real(num); 98 num = real (num);
95 endif 99 endif
100
96 endfunction 101 endfunction
97