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.
Why are my lines not showing on my graph ?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件)
Star Strider
2021 年 12 月 10 日
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)
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')
.
3 件のコメント
Star Strider
2021 年 12 月 10 日
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
2021 年 12 月 10 日
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.
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!