we have this system by its state representation :
the formulation of the quardatic command is described by the following equations:
exemple :
we would like to apply the quardatic command so that the output y(k) = x1(k) follows a certain reference.
For reference = 5 , this is the code :
clear, clc
Ac=[0 1;0 0]; Bc=[0;1]; Cc=[1 0]; Dc=0;
[A,B,C,D]=c2dm(Ac,Bc,Cc,Dc,0.1)
N=600;
ref=5;
Q=[1 2;2 1] ; R=0.1;
P=Q;
x_ref=[ref;0];
for k=N:-1:0
F=R+B'*P*B;
K=inv(F)*B'*P*A;
M=P-P*B*inv(F)*B'*P;
P=A'*M*A+Q;
end
u=0 ; x=[0;0];
for i=1:N
x=A*x+B*u;
u=-K*(x-x_ref);
y(i)=C*x;
end
plot(1:N,ref*ones(1,N),'r',1:N,y)
I get the following figure:
And now i would like to use the same code by modifying the reference signal, so as to obtain nearly these 2 curves:
y= red curve , reference= black curve
The goal is that the signal y (i) follows a non-fixed reference:
ref = 8 in [0.200]
ref = 5 in [200,400]
ref = 12 in [400,600]
This is the reference to follow :
if anyone can help me, i will be very grateful
2 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/509303-how-to-change-the-reference#comment_806028
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/509303-how-to-change-the-reference#comment_806028
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/509303-how-to-change-the-reference#comment_806031
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/509303-how-to-change-the-reference#comment_806031
Sign in to comment.