How to draw this figure ?

2 views (last 30 days)
Alan Robertson
Alan Robertson on 5 Mar 2020
Hello !
How can I draw this figure so that y(i) follows it?
This is the figure :
And this is the code to modify ( i think "ref") :
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)
ref=5;
N=600;
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)

Answers (0)

Categories

Find more on Graphics Object Identification in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!