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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
3430
|
19 |
|
20 ## -*- texinfo -*- |
5016
|
21 ## @deftypefn {Function File} {[@var{num}, @var{den}] =} ss2tf (@var{a}, @var{b}, @var{c}, @var{d}) |
7001
|
22 ## Conversion from transfer function to state-space. |
5016
|
23 ## The state space system: |
|
24 ## @iftex |
|
25 ## @tex |
|
26 ## $$ \dot x = Ax + Bu $$ |
|
27 ## $$ y = Cx + Du $$ |
|
28 ## @end tex |
|
29 ## @end iftex |
|
30 ## @ifinfo |
|
31 ## @example |
3430
|
32 ## . |
|
33 ## x = Ax + Bu |
|
34 ## y = Cx + Du |
5016
|
35 ## @end example |
|
36 ## @end ifinfo |
3430
|
37 ## |
5016
|
38 ## is converted to a transfer function: |
|
39 ## @iftex |
|
40 ## @tex |
|
41 ## $$ G(s) = { { \rm num }(s) \over { \rm den }(s) } $$ |
|
42 ## @end tex |
|
43 ## @end iftex |
|
44 ## @ifinfo |
|
45 ## @example |
3430
|
46 ## |
|
47 ## num(s) |
|
48 ## G(s)=------- |
|
49 ## den(s) |
5016
|
50 ## @end example |
|
51 ## @end ifinfo |
3430
|
52 ## |
5016
|
53 ## used internally in system data structure format manipulations. |
3430
|
54 ## @end deftypefn |
|
55 |
|
56 ## Author: R. Bruce Tenison <btenison@eng.auburn.edu> |
|
57 ## Created: June 24, 1994 |
|
58 ## a s hodel: modified to allow for pure gain blocks Aug 1996 |
|
59 |
|
60 function [num, den] = ss2tf (a, b, c, d) |
|
61 |
|
62 ## Check args |
|
63 [n,m,p] = abcddim(a,b,c,d); |
|
64 if (n == -1) |
|
65 num = []; |
|
66 den = []; |
|
67 error("ss2tf: Non compatible matrix arguments"); |
|
68 elseif ( (m != 1) | (p != 1)) |
|
69 num = []; |
|
70 den = []; |
|
71 error(["ss2tf: not SISO system: m=",num2str(m)," p=",num2str(p)]); |
|
72 endif |
|
73 |
|
74 if(n == 0) |
|
75 ## gain block only |
|
76 num = d; |
|
77 den = 1; |
|
78 else |
|
79 ## First, get the denominator coefficients |
|
80 den = poly(a); |
|
81 |
|
82 ## Get the zeros of the system |
|
83 [zz,g] = tzero(a,b,c,d); |
|
84 |
|
85 ## Form the Numerator (and include the gain) |
|
86 if (!isempty(zz)) |
|
87 num = g * poly(zz); |
|
88 else |
|
89 num = g; |
|
90 endif |
|
91 |
|
92 ## the coefficients must be real |
|
93 den = real(den); |
|
94 num = real(num); |
|
95 endif |
|
96 endfunction |
|
97 |