70
|
1 function [n, m, p] = abcddim (a, b, c, d) |
60
|
2 |
70
|
3 # Usage: [n, m, p] = abcddim (a, b, c, d) |
60
|
4 # |
|
5 # Check for compatibility of the dimensions of the matrices defining |
|
6 # the linear system (a, b, c, d). |
|
7 # |
70
|
8 # Returns n = number of system states, |
|
9 # m = number of system inputs, |
|
10 # p = number of system outputs. |
60
|
11 # |
70
|
12 # Returns n = m = p = -1 if the system is not compatible. |
|
13 |
|
14 # Written by A. S. Hodel (scotte@eng.auburn.edu) August 1993 |
60
|
15 |
|
16 if (nargin != 4) |
70
|
17 error ("abcddim: illegal number of arguments. need four.") |
60
|
18 endif |
|
19 |
70
|
20 n = m = p = -1; |
60
|
21 |
70
|
22 [an, am] = size(a); |
60
|
23 if (an != am) |
70
|
24 fprintf (stderr, "abcddim: a is not square"); |
60
|
25 return; |
|
26 endif |
|
27 |
70
|
28 [bn, bm] = size(b); |
60
|
29 if (bn != am) |
70
|
30 fprintf (stderr, "abcddim: a and b are not compatible"); |
60
|
31 return; |
|
32 endif |
|
33 |
70
|
34 [cn, cm] = size(c); |
60
|
35 if (cm != an) |
70
|
36 fprintf (stderr, "abcddim: a and c are not compatible"); |
60
|
37 return; |
|
38 endif |
|
39 |
70
|
40 [dn, dm] = size(d); |
60
|
41 if (cn != dn) |
70
|
42 fprintf (stderr, "abcddim: c and d are not compatible"); |
60
|
43 return; |
|
44 endif |
|
45 |
|
46 if (bm != dm) |
70
|
47 fprintf (stderr, "abcddim: b and d are not compatible"); |
60
|
48 return; |
|
49 endif |
|
50 |
|
51 n = an; |
|
52 m = bm; |
|
53 p = cn; |
|
54 |
|
55 endfunction |