Index in position 2 exceed array bound (must not exceed 1)?
8 ビュー (過去 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(size(t));
x0 = [1 0 0];
[y,t,x]= lsim(syscl,ones(size(t)),t);
figure(1);
plot(t,y,'r');
obpole1 = -0.5+1i;
obpole2 = -0.5-1i;
obpole3 = -0.7;
L = place(A',C', [obpole1 obpole2 obpole3])';
At = [A-B*Kt B*Kt ; zeros(size(A)) A-L*C];
Bt = [ B ; zeros(size(B))];
Ct = [ C zeros(size(C)) ];
obsys = ss(At, Bt, Ct, 0);
x0ob = [0 0 0];
[yob,t,xob] = lsim(obsys,ones(size(t)),t,[x0 x0ob]);
figure(2);
plot(t,yob,'b');
figure(3);
plot(t,yob(:,1),'r');
hold on
plot(t,yob(:,2),'b');
hold on
plot(t,y(:,1),'--r');
hold on
plot(t,y(:,2),'--b')
0 件のコメント
回答 (2 件)
Yusuf Suer Erdem
2021 年 12 月 10 日
編集済み: Yusuf Suer Erdem
2021 年 12 月 10 日
your 'yob' matrix has a single column but you are asking for its second column. that is why it is happening. recover it please.
0 件のコメント
Walter Roberson
2021 年 12 月 10 日
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(size(t));
x0 = [1 0 0];
[y,t,x]= lsim(syscl,ones(size(t)),t);
figure(1);
plot(t,y,'r');
obpole1 = -0.5+1i;
obpole2 = -0.5-1i;
obpole3 = -0.7;
L = place(A',C', [obpole1 obpole2 obpole3])';
At = [A-B*Kt B*Kt ; zeros(size(A)) A-L*C];
Bt = [ B ; zeros(size(B))];
Ct = [ C zeros(size(C)) ];
obsys = ss(At, Bt, Ct, 0);
x0ob = [0 0 0];
obsys
tf(obsys)
[yob,t,xob] = lsim(obsys,ones(size(t)),t,[x0 x0ob]);
figure(2);
plot(t,yob,'b');
size(yob)
figure(3);
plot(t,yob(:,1),'r');
hold on
plot(t,yob(:,2),'b');
hold on
plot(t,y(:,1),'--r');
hold on
plot(t,y(:,2),'--b')
Notice the transfer function equivalent is one input to one output. Notice that your state space C only has one row, and so defines only one output.
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!