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