comparison scripts/control/are.m @ 55:b973bf9a9dba

[project @ 1993-08-11 21:42:23 by jwe]
author jwe
date Wed, 11 Aug 1993 21:42:23 +0000
parents e90ea9cbd4de
children f3c9042fd609
comparison
equal deleted inserted replaced
54:98eb51c870b2 55:b973bf9a9dba
1 function x = are(a,b,c,opt) 1 function x = are (a, b, c, opt)
2 2
3 # usage: x = are (a, b, c {,opt})
3 # 4 #
4 # usage: x = are(a,b,c{,opt}) 5 # Solves algebraic riccati equation
5 # 6 #
6 # solves algebraic riccati equation 7 # a' x + x a - x b x + c = 0
7 # 8 #
8 # a' x + x a - x b x + c = 0 9 # for identically dimensioned square matrices a, b, c. If b (c) is not
10 # square, then the function attempts to use b * b' (c' * c) instead.
9 # 11 #
10 # for identically dimensioned square matrices a,b,c. If b (c) is not square, 12 # opt is an option passed to the eigenvalue balancing routine; default
11 # then the function attempts to use b*b' (c'*c) instead. 13 # is `B'.
12 #
13 # opt is an option passed to the eigenvalue balancing routine; default is 'B'
14 # 14 #
15 # see also: balance 15 # see also: balance
16 16
17 if((nargin == 3) || (nargin == 4)) 17 if (nargin == 3 || nargin == 4)
18 if(nargin==4) 18 if (nargin == 4)
19 if((opt ~= 'N') || (opt ~= 'P') || (opt ~= 'S') || (opt ~= 'B')) 19 if (! (strcmp (opt, "N") || strcmp (opt, "P") ...
20 printf('warning: are: opt has an illegal value; setting to B'); 20 || strcmp (opt, "S") || strcmp (opt, "B") ...
21 opt = 'B'; 21 || strcmp (opt, "n") || strcmp (opt, "p") ...
22 || strcmp (opt, "s") || strcmp (opt, "b")))
23 printf ("warning: are: opt has an illegal value; setting to B");
24 opt = "B";
25 endif
26 else
27 opt = "B";
22 endif 28 endif
29 if ((n = is_square(a)) == 0)
30 error ("are: a is not square");
31 endif
32
33 if (is_controllable(a,b) == 0)
34 printf("warning: are: a, b are not controllable");
35 endif
36 if ((m = is_square (b)) == 0)
37 b = b * b';
38 m = rows (b);
39 endif
40 if (is_observable (a, c) == 0)
41 printf ("warning: are: a,c are not observable");
42 endif
43 if ((p = is_square (c)) == 0)
44 c = c' * c;
45 p = rows (c);
46 endif
47 if (n != m || n != p)
48 error ("are: a, b, c not conformably dimensioned.");
49 endif
50
51 # Should check for controllability/observability here
52 # use Boley-Golub (Syst. Contr. Letters, 1984) method, not the
53 #
54 # n-1
55 # rank ([ B A*B ... A^ *B]) method
56
57 [u, s] = schur (balance ([a, -b; -c, -a'], opt), "A");
58 n1 = n + 1;
59 n2 = 2 * n;
60 x = u (n1:n2, 1:n) / u (1:n, 1:n);
23 else 61 else
24 opt = 'B'; 62 error("usage: x = are (a, b, c)")
25 endif
26 if( (n = is_square(a) ) == 0)
27 error('are: a is not square')
28 endif
29 if(is_controllable(a,b) == 0)
30 printf('warning: are: a,b are not controllable')
31 endif
32 if( (m = is_square(b)) == 0)
33 b = b*b';
34 m = rows(b);
35 endif
36 if(is_observable(a,c) == 0)
37 printf('warning: are: a,c are not observable')
38 endif
39 if( (p = is_square(c)) == 0)
40 c = c'*c;
41 p = rows(c);
42 endif
43 if( (n ~= m) || (n ~= p))
44 error('are: a,b,c not conformably dimensioned.')
45 endif 63 endif
46 64
47 # should check for controllability/observability here
48 # use Boley-Golub (Syst. Contr. Letters, 1984) method, not the
49 # n-1
50 # rank([ B A*B ... A^ *B]) method
51
52 [u,s] = schur(balance([a,-b;-c,-a'],opt),'A');
53 n1=n+1;
54 n2 = 2*n;
55 x = u(n1:n2,1:n)/u(1:n,1:n);
56 else
57 error('usage: x = are(a,b,c)')
58 endif
59
60 endfunction 65 endfunction