comparison scripts/control/abcddim.m @ 60:671f8bf989d8

[project @ 1993-08-13 21:03:40 by jwe] Initial revision
author jwe
date Fri, 13 Aug 1993 21:03:40 +0000
parents
children a5e8b7c9a3ad
comparison
equal deleted inserted replaced
59:2d10ab3ee69d 60:671f8bf989d8
1 function [n, m, p] = abcdchk (a, b, c, d)
2
3 # Usage: [n, m, p] = abcdchk (a, b, c, d)
4 #
5 # Check for compatibility of the dimensions of the matrices defining
6 # the linear system (a, b, c, d).
7 #
8 # returns n = number of system states,
9 # m = number of system inputs
10 # p = number of system outputs
11 #
12 # returns n = m = p = -1 if system is not compatible
13
14 if (nargin != 4)
15 error ("abcdchk: illegal number of arguments. Need four.")
16 endif
17
18 n = -1;
19 m = -1;
20 p = -1;
21
22 [an, am] = size (a);
23 if (an != am)
24 disp ("abcdchk: a is not square");
25 return;
26 endif
27
28 [bn, bm] = size (b);
29 if (bn != am)
30 disp ("abcdchk: a, b are not compatible");
31 return;
32 endif
33
34 [cn, cm] = size (c);
35 if (cm != an)
36 disp ("abcdchk: a, c are not compatible");
37 return;
38 endif
39
40 [dn, dm] = size (d);
41 if (cn != dn)
42 disp ("abcdchk: c, d are not compatible");
43 return;
44 endif
45
46 if (bm != dm)
47 disp ("abcdchk: b, d are not compatible");
48 return;
49 endif
50
51 n = an;
52 m = bm;
53 p = cn;
54
55 endfunction