File: mixed.dem

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (60 lines) | stat: -rw-r--r-- 1,848 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright INRIA
mode(-1)
exec(SCI+'/demos/control/scheme.dem');
x_message(['Mixed Sensitivity Controller Design';
           'file: '+SCI+'/demos/control/scheme.dem'])
mode(1)
s=poly(0,'s');
str='[(s-1)/((s-1)^2*(s+2))]';
rep=x_dialog('Nominal plant?',str)
if rep==[] then return,end
Plant=evstr(rep);Plant=syslin('c',Plant);
 //Nominal Plant
P22=tf2ss(Plant);    //...in state-space form
[ny,nu,nx]=size(P22);
[Pms,r]=augment(P22);
txt=['W1 (sensitivity function S)';'W2 (K*S)';'W3 (complementary sensitivity T)'];
default=['s';'1';'1'];
while %t
  rep=x_mdialog('Set weighting functions',txt,default);
  if rep==[] then return;end
  W1=evstr(rep(1));W2=evstr(rep(2));W3=evstr(rep(3));
  default=rep;
  Pms=sysdiag(W1,W2,W3,eye(P22))*Pms;
  gms=['gamma min= ';'gamma max= ';'# iterations'];
  vals=['0.01';'1000';'50'];
  reps=x_mdialog('Set interval for gamma and #iterations',gms,vals);
  if reps==[] then return;end
  mumin=1/evstr(reps(2))^2;
  mumax=1/evstr(reps(1))^2;
  iter=evstr(reps(3));
  [K,mu]=h_inf(Pms,r,mumin,mumax,iter);
  if K~=[] then break;end
end

disp(spec(h_cl(Pms,r,K)),'closed loop eigenvalues')    //Check internal stability
[Ssens,Rsens,Tsens]=sensi(P22,K);  //Sensitivity functions
x_message('Singular values plot')
fcts=['S function';'R (=K*S) function';'T function'];
www=x_mdialog('Select sensitivity function',fcts,['Yes';'No';'Yes']);
if www==[] then return,end
ww1=part(www(1),1)=='Y';
if ww1 then
  xbasc(1);xset("window",1);xselect();gainplot(Ssens)
  xtitle('S = Sensitivity function');
  xend()
end

ww2=part(www(2),1)=='Y';
if ww2 then
  xbasc(2);xset("window",2);xselect();gainplot(Rsens);
  xtitle('R (=G*S) Sensitivity function');
  xend()
end

ww3=part(www(3),1)=='Y';
if ww3 then
  xbasc(3);xset("window",3);xselect();gainplot(Tsens);
  xtitle('T = Complementary Sensitivity function');
  xend()
end