annotate scripts/control/hinf/dgkfdemo.m @ 7016:93c65f2a5668

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