필터 지우기
필터 지우기

3 d array to 2d array

조회 수: 1 (최근 30일)
Nur Amalina
Nur Amalina 2020년 4월 16일
댓글: Mehmed Saad 2020년 4월 16일
Hi All!
I am trying to fix this code
e = [0 1 0 1;1 0 1 1;0 1 0 1;1 1 1 0];
x = [0;0;0;0;0;0];
a1=2;
a2=4;
for t = 2:100
x(:,2)=[1;2;3;4;5;6];
for i=1:6
for j=1:6
u(i,j,t)=a1*e(i,j)*(x(j,t)-x(i,t))+a2*(x(i,t)-x(i,t-1));
end
end
u=sum(u,2);
u=permute(u,[1 3 2]);
end
I keep getting error warning like this "u(i,j,t) Index in position 2 exceeds array bounds (must not exceed 2)." I think the problem is in the initial x. what i want is when t = 1, x = [0;0;0;0;0;0]; and when t is 2 x=[1;2;3;4;5;6]; and the solution can give me u (i,t)
May anyone help me? thanks in advance!
  댓글 수: 1
Mehmed Saad
Mehmed Saad 2020년 4월 16일
what about t= 3,4,5, ....

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by