File: gfrancis.sci

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 (55 lines) | stat: -rw-r--r-- 1,948 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
function [L,M,T]= gfrancis(Plant,Model);
// This function computes an optimal model matching
// controller for the linear plant
//    x'= F*x + G*u 
//    y = H*x + J*u
// and the linear model
//    xm'= A*xm + B*um
//    ym = C*xm + D*um
// The dimensions of x,u,y are n,m,p and those of xm,um,ym are
// nn,mm,pp and pp=p.
// The goal is for the plant to track the model
//    e = y - ym ---> 0
// while keeping stable the state x(t) of the plant. To accomplish
// this, we use feedforward and feedback
//    u = L*xm + M*um + K*(x-T*xm) = [K , L-K*T] *(x,xm) + M*um
// to drive the combined system to the closed loop invariant subspace
//    x = T*xm
// where e = 0.
// The matrices T,L,M satisfy generalized Francis equations
//    F*T + G*L = T*A
//    H*T + J*L = C
//          G*M = T*B
//          J*M = D
// The matrix K is chosen as stabilizing the pair (F,G) i.e
// F+G*K is stable.
// For more information on this approach, see 
// Krener, A. J., Optimal model matching controllers for linear
// and nonlinear systems, Proceedings of NOLCOS, Bordeaux, 1992.
// Copyright INRIA
[F,G,H,J]=Plant(2:5);
[A,B,C,D]=Model(2:5);
[nf,nf]=size(F);[ny,nu]=size(J);
[na,na]=size(A);[lc,num]=size(D);
Ia=eye(na,na);Inf=eye(nf,nf);Iu=eye(num,num);
Mat=[Ia.*.F-A'.*.Inf, Ia.*.G, zeros(nf*na,nu*num);
     Ia.*.H , Ia.*.J, zeros(ny*na,nu*num);
     -B'.*.Inf, zeros(nf*num,nu*na), Iu.*.G;
      zeros(ny*num,nf*na),zeros(ny*num,nu*na),Iu.*.J];

rhs=[zeros(nf*na,1);
     matrix(C,size(C,'*'),1);
     zeros(nf*num,1);
     matrix(D,size(D,'*'),1)];
TLM=pinv(Mat)*rhs;
T=TLM(1:nf*na);T=matrix(T,nf,na);
L=TLM(nf*na+1:nf*na+nu*na);L=matrix(L,nu,na);
M=TLM(nf*na+nu*na+1:nf*na+nu*na+nu*num);M=matrix(M,nu,num);
Wplant=[F,G;H,J];
Wmodel=[A,B;C,D];
//check
err=norm(Wplant*[T,zeros(nf,num);
                 L,M]-[T,zeros(nf,lc);
                       zeros(lc,na),eye(lc,lc)]*Wmodel,1);
if err > 1.d-5 then warning('Francis equations not satisfied!');end