annotate scripts/control/dgkfdemo.m @ 3397:1a8e2c0d627a

[project @ 1999-12-18 03:02:18 by jwe]
author jwe
date Sat, 18 Dec 1999 03:02:45 +0000
parents a5288b88446f
children 0f515bc98460
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3397
1a8e2c0d627a [project @ 1999-12-18 03:02:18 by jwe]
jwe
parents: 3386
diff changeset
1 ## Copyright (C) 1996 Auburn University. All rights reserved.
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
2 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
3 ## This file is part of Octave.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
4 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
6 ## under the terms of the GNU General Public License as published by the
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
8 ## later version.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
9 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
13 ## for more details.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
14 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
15 ## You should have received a copy of the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
3346
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
18
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
19 ## -*- texinfo -*-
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
20 ##@deftypefn {Function File } { } dgkfdemo ( )
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
21 ## Octave Controls toolbox demo: H2/Hinfinity options demos
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
22 ##@end deftypefn
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
23
3397
1a8e2c0d627a [project @ 1999-12-18 03:02:18 by jwe]
jwe
parents: 3386
diff changeset
24 ## Written by A. S. Hodel June 1995
1a8e2c0d627a [project @ 1999-12-18 03:02:18 by jwe]
jwe
parents: 3386
diff changeset
25
3385
10f21f7ccc7f [project @ 1999-12-15 22:28:26 by jwe]
jwe
parents: 3381
diff changeset
26 function dgkfdemo ()
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
27
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
28 save_val = page_screen_output;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
29 page_screen_output = 1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
30 while (1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
31 clc
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
32 menuopt=0;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
33 while(menuopt > 10 || menuopt < 1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
34 menuopt = menu('Octave H2/Hinfinity options demo', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
35 'LQ regulator', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
36 'LG state estimator', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
37 'LQG optimal control design', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
38 'H2 gain of a system', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
39 'H2 optimal controller of a system', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
40 'Hinf gain of a system', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
41 'Hinf optimal controller of a SISO system', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
42 'Hinf optimal controller of a MIMO system', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
43 'Discrete-time Hinf optimal control by bilinear transform', ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
44 'Return to main demo menu');
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
45 endwhile
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
46 if (menuopt == 1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
47 disp('Linear/Quadratic regulator design:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
48 disp('Compute optimal state feedback via the lqr command...')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
49 help lqr
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
50 disp(' ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
51 disp('Example:')
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
52 A = [0, 1; -2, -1]
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
53 B = [0; 1]
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
54 Q = [1, 0; 0, 0]
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
55 R = 1
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
56 disp("Q = state penalty matrix; R = input penalty matrix")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
57 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
58 disp('Compute state feedback gain k, ARE solution P, and closed-loop')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
59 disp('poles as follows:');
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
60 cmd = "[k, p, e] = lqr(A,B,Q,R)";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
61 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
62 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
63 disp("A similar approach can be used for LTI discrete-time systems")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
64 disp("by using the dlqr command in place of lqr (see LQG example).")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
65 elseif (menuopt == 2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
66 disp('Linear/Gaussian estimator design:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
67 disp('Compute optimal state estimator via the lqe command...')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
68 help lqe
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
69 disp(' ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
70 disp('Example:')
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
71 A = [0, 1; -2, -1]
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
72 disp("disturbance entry matrix G")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
73 G = eye(2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
74 disp("Output measurement matrix C")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
75 C = [0, 1]
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
76 SigW = [1, 0; 0, 1]
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
77 SigV = 1
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
78 disp("SigW = input disturbance intensity matrix;")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
79 disp("SigV = measurement noise intensity matrix")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
80 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
81 disp('Compute estimator feedback gain k, ARE solution P, and estimator')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
82 disp('poles via the command: ')
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
83 cmd = "[k, p, e] = lqe(A,G,C,SigW,SigV)";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
84 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
85 disp("A similar approach can be used for LTI discrete-time systems")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
86 disp("by using the dlqe command in place of lqe (see LQG example).")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
87 elseif (menuopt == 3)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
88 disp('LQG optimal controller of a system:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
89 disp('Input accepted as either A,B,C matrices or in system data structure form')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
90 disp('in both discrete and continuous time.')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
91 disp("Example 1: continuous time design:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
92 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
93 help lqg
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
94 disp("Example system")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
95 A = [0, 1; .5, .5];
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
96 B = [0; 2];
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
97 G = eye(2)
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
98 C = [1, 1];
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
99 sys = ss2sys(A, [B, G], C);
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
100 sys = syssetsignals(sys,"in", ...
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
101 ["control input"; "disturbance 1"; "disturbance 2"]);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
102 sysout(sys)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
103 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
104 disp("Filtering/estimator parameters:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
105 SigW = eye(2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
106 SigV = 1
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
107 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
108 disp("State space (LQR) parameters Q and R are:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
109 Q = eye(2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
110 R = 1
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
111 cmd = "[K,Q1,P1,Ee,Er] = lqg(sys,SigW,SigV,Q,R,1);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
112 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
113 disp("Check: closed loop system A-matrix is")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
114 disp(" [A, B*Cc]")
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
115 disp(" [Bc*C, Ac ]")
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
116 cmd = "[Ac, Bc, Cc] = sys2ss(K);";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
117 run_cmd
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
118 cmd = "Acl = [A, B*Cc; Bc*C, Ac]";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
119 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
120 disp("Check: poles of Acl:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
121 Acl_poles = sortcom(eig(Acl))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
122 disp("Predicted poles from design = union(Er,Ee)")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
123 cmd = "pred_poles = sortcom([Er; Ee])";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
124 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
125 disp("Example 2: discrete-time example")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
126 cmd1 = "Dsys = ss2sys(A, [G, B], C, [0, 0, 0], 1);";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
127 cmd2 = "[K,Q1,P1,Ee,Er] = lqg(Dsys,SigW, SigV,Q,R);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
128 disp("Run commands:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
129 cmd = cmd1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
130 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
131 cmd = cmd2;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
132 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
133 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
134 disp("Check: closed loop system A-matrix is")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
135 disp(" [A, B*Cc]")
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
136 disp(" [Bc*C, Ac ]")
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
137 [Ac,Bc,Cc] = sys2ss(K);
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
138 Acl = [A, B*Cc; Bc*C, Ac]
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
139 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
140 disp("Check: poles of Acl:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
141 Acl_poles = sortcom(eig(Acl))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
142 disp("Predicted poles from design = union(Er,Ee)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
143 pred_poles = sortcom([Er;Ee])
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
144 elseif (menuopt == 4)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
145 disp('H2 gain of a system: (Energy in impulse response)')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
146 disp('Example 1: Stable plant:')
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
147 cmd = "A = [0, 1; -2, -1]; B = [0; 1]; C = [1, 0]; sys_poles = eig(A)";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
148 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
149 disp("Put into Packed system form:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
150 cmd = "Asys = ss2sys(A,B,C);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
151 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
152 disp("Evaluate system 2-norm (impulse response energy):");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
153 cmd = "AsysH2 = h2norm(Asys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
154 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
155 disp("Compare with a plot of the system impulse response:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
156 tt = 0:0.1:20;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
157 for ii=1:length(tt)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
158 ht(ii) = C*expm(A*tt(ii))*B;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
159 endfor
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
160 plot(tt,ht)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
161 title("impulse response of example plant")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
162 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
163 disp('Example 2: unstable plant')
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
164 cmd = "A = [0, 1; 2, 1]";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
165 eval(cmd);
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
166 cmd = "B = [0; 1]";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
167 eval(cmd);
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
168 cmd = "C = [1, 0]";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
169 eval(cmd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
170 cmd = "sys_poles = eig(A)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
171 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
172 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
173 disp('Put into system data structure form:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
174 cmd="Bsys = ss2sys(A,B,C);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
175 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
176 disp('Evaluate 2-norm:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
177 cmd = "BsysH2 = h2norm(Bsys)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
178 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
179 disp(' ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
180 prompt('NOTICE: program returns a value without an error signal.')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
181 disp('')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
182
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
183 elseif (menuopt == 5)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
184 disp('H2 optimal controller of a system: command = h2syn:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
185 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
186 help h2syn
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
187 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
188 disp("Example system: double integrator with output noise and")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
189 disp("input disturbance:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
190 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
191 disp(" -------------------->y2");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
192 disp(" | _________");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
193 disp("u(t)-->o-->| 1/s^2 |-->o-> y1");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
194 disp(" ^ --------- ^");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
195 disp(" | |");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
196 disp(" w1(t) w2(t)");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
197 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
198 disp("w enters the system through B1, u through B2")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
199 disp("z = [y1; y2] is obtained through C1, y=y1 through C2");
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
200 disp(" ")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
201 cmd = "A = [0, 1; 0, 0]; B1 = [0, 0; 1, 0]; B2 = [0; 1];";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
202 disp(cmd)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
203 eval(cmd);
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
204 cmd = "C1 = [1, 0; 0, 0]; C2 = [1, 0]; D11 = zeros(2);";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
205 disp(cmd)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
206 eval(cmd);
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
207 cmd = "D12 = [0; 1]; D21 = [0, 1]; D22 = 0; D = [D11, D12; D21, D22];";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
208 disp(cmd)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
209 eval(cmd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
210 disp("Design objective: compute U(s)=K(s)Y1(s) to minimize the closed")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
211 disp("loop impulse response from w(t) =[w1; w2] to z(t) = [y1; y2]");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
212 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
213 disp("First: pack system:")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
214 cmd="Asys = ss2sys(A, [B1, B2], [C1; C2], D);";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
215 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
216 disp("Open loop multivariable Bode plot: (will take a moment)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
217 cmd="bode(Asys);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
218 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
219 prompt("Press a key to close plot and continue");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
220 closeplot
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
221 disp("Controller design command: (only need 1st two output arguments)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
222 cmd="[K,gain, Kc, Kf, Pc, Pf] = h2syn(Asys,1,1);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
223 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
224 disp("Controller is:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
225 cmd = "sysout(K)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
226 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
227 disp(["returned gain value is: ",num2str(gain)]);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
228 disp("Check: close the loop and then compute h2norm:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
229 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
230 cmd="K_loop = sysgroup(Asys,K);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
231 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
232 cmd = "Kcl = sysconnect(K_loop,[3,4],[4,3]);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
233 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
234 cmd = "Kcl = sysprune(Kcl,[1,2],[1,2]);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
235 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
236 cmd="gain_Kcl = h2norm(Kcl)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
237 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
238 cmd="gain_err = gain_Kcl - gain";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
239 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
240 disp("Check: multivarible bode plot:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
241 cmd="bode(Kcl);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
242 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
243 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
244 disp("Related functions: is_dgkf, is_controllable, is_stabilizable,")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
245 disp(" is_observable, is_detectable")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
246 elseif (menuopt == 6)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
247 disp('Hinfinity gain of a system: (max gain over all j-omega)')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
248 disp('Example 1: Stable plant:')
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
249 cmd = "A = [0, 1; -2, -1]; B = [0; 1]; C = [1, 0]; sys_poles = eig(A)";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
250 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
251 disp('Pack into system format:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
252 cmd = "Asys = ss2sys(A,B,C);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
253 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
254 disp('The infinity norm must be computed iteratively by')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
255 disp('binary search. For this example, we select tolerance tol = 0.01, ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
256 disp('min gain gmin = 1e-2, max gain gmax=1e4.')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
257 disp('Search quits when upper bound <= (1+tol)*lower bound.')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
258 cmd = "tol = 0.01; gmin = 1e-2; gmax = 1e+4;";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
259 run_cmd
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
260 cmd = "[AsysHinf,gmin,gmax] = hinfnorm(Asys,tol,gmin,gmax)"
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
261 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
262 disp("Check: look at max value of magntude Bode plot of Asys:");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
263 [M,P,w] = bode(Asys);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
264 xlabel('Omega')
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
265 ylabel('|Asys(j omega)| ')
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
266 grid();
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
267 semilogx(w,M);
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
268 disp(["Max magnitude is ",num2str(max(M)), ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
269 ", compared with gmin=",num2str(gmin)," and gmax=", ...
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
270 num2str(gmax),"."])
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
271 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
272 disp('Example 2: unstable plant')
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
273 cmd = "A = [0, 1; 2, 1]; B = [0; 1]; C = [1, 0]; sys_poles = eig(A)";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
274 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
275 disp("Pack into system format:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
276 cmd = "Bsys = ss2sys(A,B,C);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
277 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
278 disp('Evaluate with BsysH2 = hinfnorm(Bsys,tol,gmin,gmax)')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
279 BsysH2 = hinfnorm(Bsys,tol,gmin,gmax)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
280 disp(' ')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
281 disp('NOTICE: program returns a value without an error signal.')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
282 disp('')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
283
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
284 elseif (menuopt == 7)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
285 disp('Hinfinity optimal controller of a system: command = hinfsyn:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
286 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
287 help hinfsyn
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
288 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
289 disp("Example system: double integrator with output noise and")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
290 disp("input disturbance:")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
291 A = [0, 1; 0, 0]
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
292 B1 = [0, 0; 1, 0]
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
293 B2 = [0; 1]
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
294 C1 = [1, 0; 0, 0]
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
295 C2 = [1, 0]
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
296 D11 = zeros(2);
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
297 D12 = [0; 1];
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
298 D21 = [0, 1];
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
299 D22 = 0;
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
300 D = [D11, D12; D21, D22]
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
301 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
302 disp("First: pack system:")
3386
a5288b88446f [project @ 1999-12-15 22:56:00 by jwe]
jwe
parents: 3385
diff changeset
303 cmd="Asys = ss2sys(A, [B1, B2], [C1; C2], D);";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
304 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
305 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
306 disp("Open loop multivariable Bode plot: (will take a moment)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
307 cmd="bode(Asys);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
308 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
309 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
310 disp("Controller design command: (only need 1st two output arguments)")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
311 gmax = 1000
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
312 gmin = 0.1
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
313 gtol = 0.01
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
314 cmd="[K,gain] = hinfsyn(Asys,1,1,gmin,gmax,gtol);";
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
315 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
316 disp("Check: close the loop and then compute h2norm:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
317 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
318 cmd="K_loop = sysgroup(Asys,K);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
319 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
320 cmd = "Kcl = sysconnect(K_loop,[3,4],[4,3]);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
321 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
322 cmd = "Kcl = sysprune(Kcl,[1,2],[1,2]);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
323 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
324 cmd="gain_Kcl = hinfnorm(Kcl)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
325 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
326 cmd="gain_err = gain_Kcl - gain";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
327 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
328 disp("Check: multivarible bode plot:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
329 cmd="bode(Kcl);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
330 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
331 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
332 disp("Related functions: is_dgkf, is_controllable, is_stabilizable,")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
333 disp(" is_observable, is_detectable, buildssic")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
334 elseif (menuopt == 8)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
335 disp('Hinfinity optimal controller of MIMO system: command = hinfsyn:')
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
336 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
337 help hinfsyn
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
338 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
339 disp("Example system: Boeing 707-321 airspeed/pitch angle control")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
340 disp(" ")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
341 hinfdemo
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
342 elseif (menuopt == 9)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
343 disp("Discrete time H-infinity control via bilinear transform");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
344 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
345 dhinfdemo
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
346 elseif (menuopt == 10)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
347 return
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
348 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
349 prompt
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
350 endwhile
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
351 page_screen_output = save_val;
3397
1a8e2c0d627a [project @ 1999-12-18 03:02:18 by jwe]
jwe
parents: 3386
diff changeset
352
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
353 endfunction