3430
|
1 ## Copyright (C) 1996 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
18 |
|
19 ## -*- texinfo -*- |
3500
|
20 ## @deftypefn {Function File} {} ss2tf (@var{inputs}) |
3430
|
21 ## @format |
|
22 ## [num,den] = ss2tf(a,b,c,d) |
|
23 ## Conversion from tranfer function to state-space. |
|
24 ## The state space system |
|
25 ## . |
|
26 ## x = Ax + Bu |
|
27 ## y = Cx + Du |
|
28 ## |
|
29 ## is converted to a transfer function |
|
30 ## |
|
31 ## num(s) |
|
32 ## G(s)=------- |
|
33 ## den(s) |
|
34 ## |
|
35 ## used internally in system data structure format manipulations |
|
36 ## @end format |
|
37 ## @end deftypefn |
|
38 |
|
39 ## Author: R. Bruce Tenison <btenison@eng.auburn.edu> |
|
40 ## Created: June 24, 1994 |
|
41 ## a s hodel: modified to allow for pure gain blocks Aug 1996 |
|
42 |
|
43 function [num, den] = ss2tf (a, b, c, d) |
|
44 |
|
45 ## Check args |
|
46 [n,m,p] = abcddim(a,b,c,d); |
|
47 if (n == -1) |
|
48 num = []; |
|
49 den = []; |
|
50 error("ss2tf: Non compatible matrix arguments"); |
|
51 elseif ( (m != 1) | (p != 1)) |
|
52 num = []; |
|
53 den = []; |
|
54 error(["ss2tf: not SISO system: m=",num2str(m)," p=",num2str(p)]); |
|
55 endif |
|
56 |
|
57 if(n == 0) |
|
58 ## gain block only |
|
59 num = d; |
|
60 den = 1; |
|
61 else |
|
62 ## First, get the denominator coefficients |
|
63 den = poly(a); |
|
64 |
|
65 ## Get the zeros of the system |
|
66 [zz,g] = tzero(a,b,c,d); |
|
67 |
|
68 ## Form the Numerator (and include the gain) |
|
69 if (!isempty(zz)) |
|
70 num = g * poly(zz); |
|
71 else |
|
72 num = g; |
|
73 endif |
|
74 |
|
75 ## the coefficients must be real |
|
76 den = real(den); |
|
77 num = real(num); |
|
78 endif |
|
79 endfunction |
|
80 |