LQ command (Linear–quadratic regulator) with another reference
3 ビュー (過去 30 日間)
古いコメントを表示
we have this system by its state representation :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275500/image.png)
the formulation of the quardatic command is described by the following equations:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275501/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275502/image.png)
exemple :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275503/image.png)
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) %Converting to discrete mode
N=600;
ref=5; %The reference
Q=[1 2;2 1] ; R=0.1;
P=Q;
x_ref=[ref;0];
for k=N:-1:0
F=R+B'*P*B; %Equation 1
K=inv(F)*B'*P*A; %Equation 2
M=P-P*B*inv(F)*B'*P; %Equation 3
P=A'*M*A+Q; %Equation 4
end
u=0 ; x=[0;0];
for i=1:N
x=A*x+B*u;
u=-K*(x-x_ref); %Equation 5
y(i)=C*x;
end
plot(1:N,ref*ones(1,N),'r',1:N,y)
with this program I get this figure:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275504/image.png)
it is requested to make the same program so as to follow a new reference in the following form instead of the step reference "5" :
Refernece to follow :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275505/image.png)
someone would solve this problem?
Thank you in advance
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!