3431
|
1 ## Copyright (C) 1993, 1994, 1995 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. |
3431
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {[@var{n}, @var{m}, @var{p}] =} abcddim (@var{a}, @var{b}, @var{c}, @var{d}) |
|
22 ## Check for compatibility of the dimensions of the matrices defining |
|
23 ## the linear system |
|
24 ## @iftex |
|
25 ## @tex |
|
26 ## $[A, B, C, D]$ corresponding to |
|
27 ## $$ |
|
28 ## \eqalign{ |
|
29 ## {dx\over dt} &= A x + B u\cr |
|
30 ## y &= C x + D u} |
|
31 ## $$ |
|
32 ## @end tex |
|
33 ## @end iftex |
|
34 ## @ifinfo |
|
35 ## [A, B, C, D] corresponding to |
|
36 ## |
|
37 ## @example |
|
38 ## dx/dt = a x + b u |
|
39 ## y = c x + d u |
|
40 ## @end example |
|
41 ## |
|
42 ## @end ifinfo |
|
43 ## or a similar discrete-time system. |
|
44 ## |
|
45 ## If the matrices are compatibly dimensioned, then @code{abcddim} returns |
|
46 ## |
|
47 ## @table @var |
|
48 ## @item n |
|
49 ## The number of system states. |
|
50 ## |
|
51 ## @item m |
|
52 ## The number of system inputs. |
|
53 ## |
|
54 ## @item p |
|
55 ## The number of system outputs. |
|
56 ## @end table |
|
57 ## |
|
58 ## Otherwise @code{abcddim} returns @var{n} = @var{m} = @var{p} = @minus{}1. |
|
59 ## |
|
60 ## Note: n = 0 (pure gain block) is returned without warning. |
|
61 ## |
|
62 ## @end deftypefn |
5053
|
63 ## |
3431
|
64 ## @seealso{is_abcd} |
|
65 |
|
66 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
67 ## Created: August 1993. |
|
68 ## a s hodel: modified to accept pure-gain systems aug 1996 |
|
69 |
|
70 function [n, m, p] = abcddim (a, b, c, d) |
|
71 |
|
72 if (nargin != 4) |
|
73 error ("abcddim: four arguments required"); |
|
74 endif |
|
75 |
|
76 n = m = p = -1; |
|
77 |
3438
|
78 [a, an, am] = __abcddims__ (a); |
|
79 [b, bn, bm] = __abcddims__ (b); |
|
80 [c, cn, cm] = __abcddims__ (c); |
|
81 [d, dn, dm] = __abcddims__ (d); |
3431
|
82 |
4030
|
83 if ( (!issquare(a)) & (!isempty(a)) ) |
3431
|
84 warning (["abcddim: a is not square (",num2str(an),"x",num2str(am),")"]); |
|
85 return |
|
86 endif |
|
87 |
|
88 if( (bm == 0) & (dm == 0) ) |
|
89 warning("abcddim: no inputs"); |
|
90 elseif (bn != am) |
|
91 warning (["abcddim: a(",num2str(an),"x",num2str(am), ... |
|
92 " and b(",num2str(bn),"x",num2str(bm),") are not compatible"]); |
|
93 return |
|
94 endif |
|
95 |
|
96 if( (cn == 0) & (dn == 0 ) ) |
|
97 warning("abcddim: no outputs"); |
|
98 elseif (cm != an) |
|
99 warning (["abcddim: a(",num2str(an),"x",num2str(am), ... |
|
100 " and c(",num2str(cn),"x",num2str(cm),") are not compatible"]); |
|
101 return |
|
102 endif |
|
103 |
|
104 have_connections = (bn*cn != 0); |
|
105 |
|
106 if( (dn == 0) & have_connections) |
|
107 warning("abcddim: empty d matrix passed; setting compatibly with b, c"); |
3438
|
108 [d, dn, dm] = __abcddims__ (zeros (cn, bm)); |
3431
|
109 endif |
|
110 |
|
111 if(an > 0) |
|
112 [dn, dm] = size(d); |
|
113 if ( (cn != dn) & have_connections ) |
|
114 warning (["abcddim: c(",num2str(cn),"x",num2str(cm), ... |
|
115 " and d(",num2str(dn),"x",num2str(dm),") are not compatible"]); |
|
116 return |
|
117 endif |
|
118 |
|
119 if ( (bm != dm) & have_connections ) |
|
120 warning (["abcddim: b(",num2str(bn),"x",num2str(bm), ... |
|
121 " and d(",num2str(dn),"x",num2str(dm),") are not compatible"]); |
|
122 return |
|
123 endif |
|
124 |
|
125 m = bm; |
|
126 p = cn; |
|
127 else |
|
128 [p,m] = size(d); |
|
129 endif |
|
130 n = an; |
|
131 endfunction |