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!