Index in position 2 exceeds array bounds. Index must not exceed 1.
How to fix errors? "Index in position 2 exceeds array bounds. Index must not exceed 1".
Thanks for everyone’s help
Error in VU_MSSP_2024_QUYDAO (line 72)
Xv_2(s,i+1)=-inv(A_0(4,4))*(A_0(4,1)*Xh(s,i+1)+A_0(4,2)*Xeh(s,i+1)+A_0(4,3)*Xv_1(s,i+1)+A_0(4,5)*Xev_1(s,i+1)+A_0(4,6)*Xev_2(s,i+1)+B_0(4,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
clc
clear all;
close all;
I_1=[1];
I_2=[1 0;0 1];
Eh=[1];
Ev=[1 0;0 0];
E=blkdiag(Eh,Ev);
E_c=blkdiag(Eh,Eh,Ev,Ev);
Ih=[1];
Iv=[1 0;0 1];
J=[Ih zeros(1,5);zeros(2,2) Iv zeros(2,2);0 Ih zeros(1,4); zeros(2,2) zeros(2,2) Iv];
A=[0.04 -0.01 0.3;0.01 0.9 0.3;0.15 0.01 -0.05];
H=[-0.02 0.01 0.02;0.05 -0.01 0.05;0.47 0.01 2.02];
C=[0.05 -0.02 0.05;-0.05 0.01 0.08];
B_u=[0.01;0.02;-0.01];
B_w=[-0.02;0.05;0.04];
D_u=[0.05;0.01];
D_w=[0.02;-0.03];
A_c=blkdiag(A,A);
B_wc=[B_w;B_w];
B_c=[B_u -B_u;zeros(3,1) zeros(3,1)];
H_c=[zeros(3,3) zeros(3,3); zeros(3,3) H];
N_E=[zeros(1,6);zeros(1,6);zeros(1,6);1 1 1 1 1 1;zeros(1,6);1 1 1 -1 1 1];
D_1=[D_u -D_u];
%——————–
a=0.8;
gamma=4;
K=[ -0.4957 -9.2860 -4.8612];
L=[ -1726 -1094 43;950 603 -24;-18404 -11652 457];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A_0=J’*[A+B_u*K -B_u*K;zeros(3,3) A-L*H]*J;
B_0=J’*[B_w;B_w];
C_0=[C+D_u*K -D_u*K]*J;
n=80;
v=ze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+i))*sin(i+s);
Xv_1(s,i+1)=A_0(3,1)*Xh(s,i)+A_0(3,2)*Xeh(s,i)+A_0(3,3)*Xv_1(s,i)+A_0(3,4)*Xv_2(s,i)+A_0(3,5)*Xev_1(s,i)+A_0(3,6)*Xev_2(s,i)+B_0(3,1)*5*exp(-0.1*(s+i))*sin(i+s);
Xv_2(s,i+1)=-inv(A_0(4,4))*(A_0(4,1)*Xh(s,i+1)+A_0(4,2)*Xeh(s,i+1)+A_0(4,3)*Xv_1(s,i+1)+A_0(4,5)*Xev_1(s,i+1)+A_0(4,6)*Xev_2(s,i+1)+B_0(4,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
Xev_1(s,i+1)=A_0(5,1)*Xh(s,i)+A_0(5,2)*Xeh(s,i)+A_0(5,3)*Xv_1(s,i)+A_0(5,4)*Xv_2(s,i)+A_0(5,5)*Xev_1(s,i)+A_0(5,6)*Xev_2(s,i)+B_0(5,1)*5*exp(-0.1*(s+i))*sin(i+s);
Xev_2(s,i+1)=-inv(A_0(6,6))*(A_0(6,1)*Xh(s,i+1)+A_0(6,2)*Xeh(s,i+1)+A_0(6,3)*Xv_1(s,i+1)+A_0(6,4)*Xv_2(s,i+1)+A_0(6,5)*Xev_1(s,i+1)+B_0(6,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
Z(s,i)=norm(C_0*x0+D_w*5*exp(-0.1*(s+i))*sin(i+s));
U(s,i)=K*([Xh(s,i);Xv_1(s,i);Xv_2(s,i)]-[Xeh(s,i);Xev_1(s,i);Xev_2(s,i)]);
end
end
figure(1)
surf(v,w,Xh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x^h(i,j)’);
%axis([0 100 0 100 -0.15 0.06])
hold on;
figure(2)
surf(v,w,Xeh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_e^h(i,j)’);
%axis([0 100 0 100 -0.5 0.1])
hold on;
figure(3)
surf(v,w,Xv_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_1^v(i,j)’);
hold on;
figure(4)
surf(v,w,Xv_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_2^v(i,j)’);
hold on;
figure(5)
surf(v,w,Xev_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e1}^v(i,j)’);
hold on;
figure(6)
surf(v,w,Xev_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e2}^v(i,j)’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(7)
surf(v,w,Z)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘||z(i,j)||’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(8)
surf(v,w,U)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘u(i,j)|’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
"How to fix errors? "Index in position 2 exceeds array bounds. Index must not exceed 1".
Thanks for everyone’s help
Error in VU_MSSP_2024_QUYDAO (line 72)
Xv_2(s,i+1)=-inv(A_0(4,4))*(A_0(4,1)*Xh(s,i+1)+A_0(4,2)*Xeh(s,i+1)+A_0(4,3)*Xv_1(s,i+1)+A_0(4,5)*Xev_1(s,i+1)+A_0(4,6)*Xev_2(s,i+1)+B_0(4,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
clc
clear all;
close all;
I_1=[1];
I_2=[1 0;0 1];
Eh=[1];
Ev=[1 0;0 0];
E=blkdiag(Eh,Ev);
E_c=blkdiag(Eh,Eh,Ev,Ev);
Ih=[1];
Iv=[1 0;0 1];
J=[Ih zeros(1,5);zeros(2,2) Iv zeros(2,2);0 Ih zeros(1,4); zeros(2,2) zeros(2,2) Iv];
A=[0.04 -0.01 0.3;0.01 0.9 0.3;0.15 0.01 -0.05];
H=[-0.02 0.01 0.02;0.05 -0.01 0.05;0.47 0.01 2.02];
C=[0.05 -0.02 0.05;-0.05 0.01 0.08];
B_u=[0.01;0.02;-0.01];
B_w=[-0.02;0.05;0.04];
D_u=[0.05;0.01];
D_w=[0.02;-0.03];
A_c=blkdiag(A,A);
B_wc=[B_w;B_w];
B_c=[B_u -B_u;zeros(3,1) zeros(3,1)];
H_c=[zeros(3,3) zeros(3,3); zeros(3,3) H];
N_E=[zeros(1,6);zeros(1,6);zeros(1,6);1 1 1 1 1 1;zeros(1,6);1 1 1 -1 1 1];
D_1=[D_u -D_u];
%——————–
a=0.8;
gamma=4;
K=[ -0.4957 -9.2860 -4.8612];
L=[ -1726 -1094 43;950 603 -24;-18404 -11652 457];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A_0=J’*[A+B_u*K -B_u*K;zeros(3,3) A-L*H]*J;
B_0=J’*[B_w;B_w];
C_0=[C+D_u*K -D_u*K]*J;
n=80;
v=zeros(1,n);
w=zeros(1,n);
Xh=zeros(n,n); Xeh=zeros(n,n); Xv_1=zeros(n,n);Xv_2=zeros(n,n);Ev_1=zeros(n,n);Xev_2=zeros(n,n);Z=zeros(n,n);U=zeros(n,n);
for i=1:1:n-1
Xh(1,i)=0;
Xeh(1,i)=0;
end
for i=1:1:n-1
Xv_1(i,1)=0;
Xv_2(i,1)=0;
Xev_1(i,1)=0;
Xev_2(i,1)=0;
end
x1=zeros(6,1);x0=zeros(6,1);xc=zeros(6,1);
for i=1:1:n
v(1,i)=i;
w(1,i)=i;
end
for s=1:1:n
for i=1:1:n-1
x0(1,1)=Xh(s,i);x0(2,1)=Xeh(s,i);x0(3,1)=Xv_1(s,i);x0(4,1)=Xv_2(s,i);x0(5,1)=Xev_1(s,i);x0(6,1)=Xev_2(s,i);
x1=A_0*x0+B_0*5*exp(-0.1*(s+i))*sin(i+s);
Xh(s+1,i)=A_0(1,1)*Xh(s,i)+A_0(1,2)*Xeh(s,i)+A_0(1,3)*Xv_1(s,i)+A_0(1,4)*Xv_2(s,i)+A_0(1,5)*Xev_1(s,i)+A_0(1,6)*Xev_2(s,i)+B_0(1,1)*5*exp(-0.1*(s+i))*sin(i+s);
Xeh(s+1,i)=A_0(2,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s,i+1)+B_0(6,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
Z(s,i)=norm(C_0*x0+D_w*5*exp(-0.1*(s+i))*sin(i+s));
U(s,i)=K*([Xh(s,i);Xv_1(s,i);Xv_2(s,i)]-[Xeh(s,i);Xev_1(s,i);Xev_2(s,i)]);
end
end
figure(1)
surf(v,w,Xh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x^h(i,j)’);
%axis([0 100 0 100 -0.15 0.06])
hold on;
figure(2)
surf(v,w,Xeh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_e^h(i,j)’);
%axis([0 100 0 100 -0.5 0.1])
hold on;
figure(3)
surf(v,w,Xv_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_1^v(i,j)’);
hold on;
figure(4)
surf(v,w,Xv_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_2^v(i,j)’);
hold on;
figure(5)
surf(v,w,Xev_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e1}^v(i,j)’);
hold on;
figure(6)
surf(v,w,Xev_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e2}^v(i,j)’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(7)
surf(v,w,Z)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘||z(i,j)||’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(8)
surf(v,w,U)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘u(i,j)|’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
" How to fix errors? "Index in position 2 exceeds array bounds. Index must not exceed 1".
Thanks for everyone’s help
Error in VU_MSSP_2024_QUYDAO (line 72)
Xv_2(s,i+1)=-inv(A_0(4,4))*(A_0(4,1)*Xh(s,i+1)+A_0(4,2)*Xeh(s,i+1)+A_0(4,3)*Xv_1(s,i+1)+A_0(4,5)*Xev_1(s,i+1)+A_0(4,6)*Xev_2(s,i+1)+B_0(4,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
clc
clear all;
close all;
I_1=[1];
I_2=[1 0;0 1];
Eh=[1];
Ev=[1 0;0 0];
E=blkdiag(Eh,Ev);
E_c=blkdiag(Eh,Eh,Ev,Ev);
Ih=[1];
Iv=[1 0;0 1];
J=[Ih zeros(1,5);zeros(2,2) Iv zeros(2,2);0 Ih zeros(1,4); zeros(2,2) zeros(2,2) Iv];
A=[0.04 -0.01 0.3;0.01 0.9 0.3;0.15 0.01 -0.05];
H=[-0.02 0.01 0.02;0.05 -0.01 0.05;0.47 0.01 2.02];
C=[0.05 -0.02 0.05;-0.05 0.01 0.08];
B_u=[0.01;0.02;-0.01];
B_w=[-0.02;0.05;0.04];
D_u=[0.05;0.01];
D_w=[0.02;-0.03];
A_c=blkdiag(A,A);
B_wc=[B_w;B_w];
B_c=[B_u -B_u;zeros(3,1) zeros(3,1)];
H_c=[zeros(3,3) zeros(3,3); zeros(3,3) H];
N_E=[zeros(1,6);zeros(1,6);zeros(1,6);1 1 1 1 1 1;zeros(1,6);1 1 1 -1 1 1];
D_1=[D_u -D_u];
%——————–
a=0.8;
gamma=4;
K=[ -0.4957 -9.2860 -4.8612];
L=[ -1726 -1094 43;950 603 -24;-18404 -11652 457];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A_0=J’*[A+B_u*K -B_u*K;zeros(3,3) A-L*H]*J;
B_0=J’*[B_w;B_w];
C_0=[C+D_u*K -D_u*K]*J;
n=80;
v=zeros(1,n);
w=zeros(1,n);
Xh=zeros(n,n); Xeh=zeros(n,n); Xv_1=zeros(n,n);Xv_2=zeros(n,n);Ev_1=zeros(n,n);Xev_2=zeros(n,n);Z=zeros(n,n);U=zeros(n,n);
for i=1:1:n-1
Xh(1,i)=0;
Xeh(1,i)=0;
end
for i=1:1:n-1
Xv_1(i,1)=0;
Xv_2(i,1)=0;
Xev_1(i,1)=0;
Xev_2(i,1)=0;
end
x1=zeros(6,1);x0=zeros(6,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,3)*Xv_1(s,i+1)+A_0(4,5)*Xev_1(s,i+1)+A_0(4,6)*Xev_2(s,i+1)+B_0(4,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
Xev_1(s,i+1)=A_0(5,1)*Xh(s,i)+A_0(5,2)*Xeh(s,i)+A_0(5,3)*Xv_1(s,i)+A_0(5,4)*Xv_2(s,i)+A_0(5,5)*Xev_1(s,i)+A_0(5,6)*Xev_2(s,i)+B_0(5,1)*5*exp(-0.1*(s+i))*sin(i+s);
Xev_2(s,i+1)=-inv(A_0(6,6))*(A_0(6,1)*Xh(s,i+1)+A_0(6,2)*Xeh(s,i+1)+A_0(6,3)*Xv_1(s,i+1)+A_0(6,4)*Xv_2(s,i+1)+A_0(6,5)*Xev_1(s,i+1)+B_0(6,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
Z(s,i)=norm(C_0*x0+D_w*5*exp(-0.1*(s+i))*sin(i+s));
U(s,i)=K*([Xh(s,i);Xv_1(s,i);Xv_2(s,i)]-[Xeh(s,i);Xev_1(s,i);Xev_2(s,i)]);
end
end
figure(1)
surf(v,w,Xh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x^h(i,j)’);
%axis([0 100 0 100 -0.15 0.06])
hold on;
figure(2)
surf(v,w,Xeh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_e^h(i,j)’);
%axis([0 100 0 100 -0.5 0.1])
hold on;
figure(3)
surf(v,w,Xv_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_1^v(i,j)’);
hold on;
figure(4)
surf(v,w,Xv_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_2^v(i,j)’);
hold on;
figure(5)
surf(v,w,Xev_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e1}^v(i,j)’);
hold on;
figure(6)
surf(v,w,Xev_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e2}^v(i,j)’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(7)
surf(v,w,Z)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘||z(i,j)||’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(8)
surf(v,w,U)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘u(i,j)|’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
" index exceeds array bounds. MATLAB Answers — New Questions