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