Why are my lines not showing on my graph ?

2 visualizzazioni (ultimi 30 giorni)
Christian Thomas
Christian Thomas il 10 Dic 2021
Commentato: Peter Bonavita il 10 Dic 2021
A = [ 1 2 -4; 1 1 4; 0 -1 4];
B = [0 ;0; 10];
C = [ 0 0 1];
D = 0;
poles = [ -0.5-1i -0.5+1i -0.7];
Kt = place(A,B,poles);
F = inv(C*inv(-A+(B*Kt))*B);
Acl=A-(B*Kt);
Bcl=B*F;
Ccl=C;
Dcl=0;
syscl=ss(Acl,Bcl,Ccl,Dcl);
t=0:0.1:10;
r=ones(1,length(t));
x0 = [1 0 0];
CL_FFFB= lsim(syscl,r,t,x0);
figure(1);
plot(t,CL_FFFB,'r-');
Nbar = rscale(syscl,Kt);
obpole1 = -3;
obpole2 = -4;
obpole3 = -6;
L = place(A', C', [obpole1 obpole2 obpole3])';
At = [A-B*Kt B*Kt ; zeros(size(A)) A-L*C];
Bt = [ B*Nbar ; zeros(size(B))];
Ct = [ C zeros(size(C)) ];
obsys = ss(At, Bt, Ct, 0);
x0ob = [0 0 0];
[yob,t,xob] = lsim(obsys,zeros(size(t)),t,[x0ob x0ob]);
figure(2);
plot(t,xob(:,1),'r');
hold on
plot(t,xob(:,2),'b');
hold on
plot(t,xob(:,1),'--r');
hold on
plot(t,xob(:,2),'--b')
  1 Commento
Christian Thomas
Christian Thomas il 10 Dic 2021
When I run the code it shows the first figure but the second figure has just a straight line with out any other vaules on it.

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 10 Dic 2021
I don’t even get a straight line, because there is not such functyion as ‘rscale’ in the online documentation.
That aside, look at the ‘C’ matris in ‘syscl’ and note that the second and third elements (columns) are 0 so the outputs related to those states are also 0. That could account for the straight line (assumed to be at 0) for those states and state trajectories.
A = [ 1 2 -4; 1 1 4; 0 -1 4];
B = [0 ;0; 10];
C = [ 0 0 1];
D = 0;
poles = [ -0.5-1i -0.5+1i -0.7];
Kt = place(A,B,poles);
F = inv(C*inv(-A+(B*Kt))*B);
Acl=A-(B*Kt);
Bcl=B*F;
Ccl=C;
Dcl=0;
syscl=ss(Acl,Bcl,Ccl,Dcl)
syscl = A = x1 x2 x3 x1 1 2 -4 x2 1 1 4 x3 -6.319 -8.906 -3.7 B = u1 x1 0 x2 0 x3 -0.875 C = x1 x2 x3 y1 0 0 1 D = u1 y1 0 Continuous-time state-space model.
t=0:0.1:10;
r=ones(1,length(t));
x0 = [1 0 0];
CL_FFFB= lsim(syscl,r,t,x0);
figure(1);
plot(t,CL_FFFB,'r-');
Nbar = rscale(syscl,Kt);
Unrecognized function or variable 'rscale'.
obpole1 = -3;
obpole2 = -4;
obpole3 = -6;
L = place(A', C', [obpole1 obpole2 obpole3])';
At = [A-B*Kt B*Kt ; zeros(size(A)) A-L*C];
Bt = [ B*Nbar ; zeros(size(B))];
Ct = [ C zeros(size(C)) ];
obsys = ss(At, Bt, Ct, 0);
x0ob = [0 0 0];
[yob,t,xob] = lsim(obsys,zeros(size(t)),t,[x0ob x0ob])
figure(2);
plot(t,xob(:,1),'r');
hold on
plot(t,xob(:,2),'b');
hold on
plot(t,xob(:,1),'--r');
hold on
plot(t,xob(:,2),'--b')
.
  3 Commenti
Star Strider
Star Strider il 10 Dic 2021
With respect to ‘rscale’ I prefer not to go looking for it, so if it is available it needs to be included in the code as a function at the end of the posted code.
With respect to the straight line, my previous observation holds, specifically that the ‘C’ matrix in ‘syscl’ has a 0 value in element 2, so those state and state trajectory outputs will be identically 0. To get a different result, replace ‘C(2)’ with some non-zero value, perhaps 1.
.
Peter Bonavita
Peter Bonavita il 10 Dic 2021
Assuming you're using this rscale from the Michigan Controls Tutorials site, the data you're plotting in xob consists of all zeros, hence the straight line at Y=0.
>> xob
xob =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Star Strider's answer is correct; they explain the zeros in the other matrices lead to zero output.

Accedi per commentare.

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by