| Revision 754, 1.0 kB
            (checked in by smidl, 16 years ago) | 
        
          | 
fixes + LQ for dual control 
 | 
      
      
    | Line |  | 
|---|
| 1 | function [ulq]  = c2008lqcM(A, B, C, Xt, yp, N, P) | 
|---|
| 2 | % function computes LQ controller for unit Qy and zero Qu with given | 
|---|
| 3 | % uncertainty matrix P, which is a N-dimensional cell of P matrices on the considered | 
|---|
| 4 | % horizon. | 
|---|
| 5 |  | 
|---|
| 6 | % vector of the quadratic form z is [u,y_{t-1},1] | 
|---|
| 7 |  | 
|---|
| 8 |  | 
|---|
| 9 | dx=size(A,1); du=size(B,2); dy=size(C,1); | 
|---|
| 10 |  | 
|---|
| 11 | Qy = eye(dy); | 
|---|
| 12 | qx=C'*Qy*C; | 
|---|
| 13 |  | 
|---|
| 14 | qux=zeros(du,dx+du+dy); | 
|---|
| 15 | if ~iscell(P) | 
|---|
| 16 | qux(:,1:du)=P; | 
|---|
| 17 | end | 
|---|
| 18 | qyx=[C,-eye(dy)]; | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | s=1e-5*eye(dx+dy); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
|---|
| 22 |  | 
|---|
| 23 | pr=[B,A, zeros(dx, dy); | 
|---|
| 24 | zeros(dy,dx+du), eye(dy)]; | 
|---|
| 25 |  | 
|---|
| 26 | hqy=Qy*qyx*pr | 
|---|
| 27 | hqy(:,du+dx+1:du+dx+dy)=-Qy*diag(yp) | 
|---|
| 28 |  | 
|---|
| 29 | nstep=N; | 
|---|
| 30 | for i=1:nstep, | 
|---|
| 31 | if iscell(P) | 
|---|
| 32 | qux(:,1:du)=P{nstep-i+1}; | 
|---|
| 33 | end | 
|---|
| 34 |  | 
|---|
| 35 | h= s*pr; | 
|---|
| 36 | pomqr=[h;hqy;qux]; | 
|---|
| 37 | hn=triu(qr(pomqr)); | 
|---|
| 38 | s=hn(du+1:end,du+1:end); | 
|---|
| 39 |  | 
|---|
| 40 | ws=hn(1:du,du+1:end); | 
|---|
| 41 | wsd=hn(1:du,1:du); | 
|---|
| 42 |  | 
|---|
| 43 | Bellman_core=s'*s | 
|---|
| 44 | L=-inv(wsd)*ws | 
|---|
| 45 | sprintf('u_t = %f y_{t-1} + %f ',L(1), L(2)) | 
|---|
| 46 |  | 
|---|
| 47 | end | 
|---|
| 48 |  | 
|---|
| 49 | ulq=L*[Xt;ones(dy,1)];                % ��zen� u na z�lad� LQ synt�zy | 
|---|
| 50 | keyboard | 
|---|
| 51 |  | 
|---|