File: mixed.dem

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (73 lines) | stat: -rw-r--r-- 2,221 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
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright INRIA
mode(-1)
//display the diagram
x=[5,10,20,40,50,70,80,90];xmin=-10;xmax=100;
y=[22,28,30,32];ymin=12;ymax=40;

xx=[xmin,xmin,x([1 2 2 7 4 6 3 4 5 6 3 3 5 5]);xmax,xmax,x([3,2,7,7,5,8,3,4,5,6,4,4,6,6])];
yy=[ymin,ymax,y([3,1,1,1,3,3,2,2,2,2,2,4,2,4]);ymin,ymax,y([3,3,1,3,3,3,4,4,4,4,2,4,2,4])];
    
xset("window",0);xbasc();xselect();
plot2d(xx,yy,ones(1,16),'022');
xstring(28,30,'K');xstring(56,30,'Plant');xstring(12,28.80,'-');
xtitle('PLANT   and   CONTROLLER')
mode(2)

x_message(['Mixed Sensitivity Controller Design';
           'file: '+SCI+'/demos/control/mixed.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
  scf(1);clf();xselect();
  gainplot(Ssens);
  xtitle('S = Sensitivity function');
end

ww2=part(www(2),1)=='Y';
if ww2 then
  scf(2);clf();xselect();
  gainplot(Rsens);
  xtitle('R (=G*S) Sensitivity function');
end

ww3=part(www(3),1)=='Y';
if ww3 then
  scf(3);clf();xselect();
  gainplot(Tsens);
  xtitle('T = Complementary Sensitivity function');
end