2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License 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 |
|
18 ## 02111-1307, USA. |
245
|
19 |
2311
|
20 ## Usage: [n, m, p] = abcddim (a, b, c, d) |
|
21 ## |
|
22 ## Check for compatibility of the dimensions of the matrices defining |
|
23 ## the linear system (a, b, c, d). |
|
24 ## |
|
25 ## Returns n = number of system states, |
|
26 ## m = number of system inputs, |
|
27 ## p = number of system outputs. |
|
28 ## |
|
29 ## Returns n = m = p = -1 if the system is not compatible. |
60
|
30 |
2312
|
31 ## Author: A. S. Hodel <scotte@eng.auburn.edu> |
|
32 ## Created: August 1993 |
|
33 ## Adapted-By: jwe |
70
|
34 |
2312
|
35 function [n, m, p] = abcddim (a, b, c, d) |
60
|
36 |
|
37 if (nargin != 4) |
1518
|
38 error ("usage: abcddim (a, b, c, d)"); |
60
|
39 endif |
|
40 |
70
|
41 n = m = p = -1; |
60
|
42 |
70
|
43 [an, am] = size(a); |
60
|
44 if (an != am) |
904
|
45 error ("abcddim: a is not square"); |
60
|
46 endif |
|
47 |
70
|
48 [bn, bm] = size(b); |
60
|
49 if (bn != am) |
904
|
50 error ("abcddim: a and b are not compatible"); |
60
|
51 endif |
|
52 |
70
|
53 [cn, cm] = size(c); |
60
|
54 if (cm != an) |
904
|
55 error ("abcddim: a and c are not compatible"); |
60
|
56 endif |
|
57 |
70
|
58 [dn, dm] = size(d); |
60
|
59 if (cn != dn) |
904
|
60 error ("abcddim: c and d are not compatible"); |
60
|
61 endif |
|
62 |
|
63 if (bm != dm) |
904
|
64 error ("abcddim: b and d are not compatible"); |
60
|
65 endif |
|
66 |
|
67 n = an; |
|
68 m = bm; |
|
69 p = cn; |
|
70 |
|
71 endfunction |