Index in position 2 exceed array bound (must not exceed 1)?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Yusuf Suer Erdem
am 10 Dez. 2021
Bearbeitet: Yusuf Suer Erdem
am 10 Dez. 2021
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 Kommentare
Walter Roberson
am 10 Dez. 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(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 Kommentare
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!