annotate scripts/control/dgkfdemo.m @ 3402:9610d364e444

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