Model predictive control question (cant figure out what's wrong with my code )

Hi all;
i was wondering if anyone can help me with this plzzz.
i'm woking on mpc modeling and i made the code that could stabilize the system and it worked..the problem is the system should have some damping at the beginning before it goes to equilibrium point...so obviously something wrong with my code ...i just cant figure it out which part of it !! :s my system is
y(t)-2.7y(t-1)+1.8y(t-2)=u(t-1)+5u(t-2)+6u(t-3)
and i'm using state space model
my code is :
% N2=10;lamda=1;Nu=2
Am=[0 1 0;0 0 1;0 -1.8 2.7];Bm=[0;0;1];Cm=[6 5 1];Dm=0;N2=10;Nu=2;[n,n1]=size(Am);
Om=zeros(n,1);A=[Am Om;Cm*Am 1];B=[Bm;Cm*Bm];C=[0 0 0 1];lamda=1;
% To get F elements
F = zeros(N2,4);R = A;
for nn = 1:N2
F(nn,:) = C*R;R = R*A;
end
%To get G1 elements
R1=A;g=zeros (N2-1,1);
for m=1:N2-1
g(m,:)=C*R1*B;R1=R1*A;G_1=[C*B ;g];G_2=[0;G_1(1:N2-1)];G=[G_1 G_2];
end
xm=[0;0;0];X=zeros(4,1);w=ones(10,1);u=0; y=0;
for i=1:500;
DeltaU=inv(G'*G+1*eye(Nu,Nu))*(G'*w*3 -G'*F*X);
du=DeltaU(1,1);u=u+du;u1(i)=u;y1(i)=y;xm1=xm;xm=Am*xm+Bm*u;y=Cm*xm;X=[xm-xm1;y];
end
k=0:(500-1);
figure
subplot(211)
plot(k,y1)
subplot(212)
plot(k,u1)

Respuestas (0)

Preguntada:

el 27 de Abr. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by