245
|
1 # Copyright (C) 1993 John W. Eaton |
|
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, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
18 |
70
|
19 function [n, m, p] = abcddim (a, b, c, d) |
60
|
20 |
70
|
21 # Usage: [n, m, p] = abcddim (a, b, c, d) |
60
|
22 # |
|
23 # Check for compatibility of the dimensions of the matrices defining |
|
24 # the linear system (a, b, c, d). |
|
25 # |
70
|
26 # Returns n = number of system states, |
|
27 # m = number of system inputs, |
|
28 # p = number of system outputs. |
60
|
29 # |
70
|
30 # Returns n = m = p = -1 if the system is not compatible. |
|
31 |
78
|
32 # Written by A. S. Hodel (scotte@eng.auburn.edu) August 1993. |
60
|
33 |
|
34 if (nargin != 4) |
70
|
35 error ("abcddim: illegal number of arguments. need four.") |
60
|
36 endif |
|
37 |
70
|
38 n = m = p = -1; |
60
|
39 |
70
|
40 [an, am] = size(a); |
60
|
41 if (an != am) |
70
|
42 fprintf (stderr, "abcddim: a is not square"); |
60
|
43 return; |
|
44 endif |
|
45 |
70
|
46 [bn, bm] = size(b); |
60
|
47 if (bn != am) |
70
|
48 fprintf (stderr, "abcddim: a and b are not compatible"); |
60
|
49 return; |
|
50 endif |
|
51 |
70
|
52 [cn, cm] = size(c); |
60
|
53 if (cm != an) |
70
|
54 fprintf (stderr, "abcddim: a and c are not compatible"); |
60
|
55 return; |
|
56 endif |
|
57 |
70
|
58 [dn, dm] = size(d); |
60
|
59 if (cn != dn) |
70
|
60 fprintf (stderr, "abcddim: c and d are not compatible"); |
60
|
61 return; |
|
62 endif |
|
63 |
|
64 if (bm != dm) |
70
|
65 fprintf (stderr, "abcddim: b and d are not compatible"); |
60
|
66 return; |
|
67 endif |
|
68 |
|
69 n = an; |
|
70 m = bm; |
|
71 p = cn; |
|
72 |
|
73 endfunction |