Index in position 2 exceed array bound (must not exceed 1)?
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Yusuf Suer Erdem
il 10 Dic 2021
Modificato: Yusuf Suer Erdem
il 10 Dic 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 Commenti
Walter Roberson
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(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 Commenti
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!