필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Index in position 1 exceeds boundaries

조회 수: 1 (최근 30일)
Griffin Polglaze
Griffin Polglaze 2020년 4월 27일
마감: MATLAB Answer Bot 2021년 8월 20일
I have just written a code for a heat transfer problem and when I run it I get an error stating 'Index in position 1 exceeds boundaries'. Apologies for the long code but if someone could point me in the right direction that would be really helpful. Thanks
  댓글 수: 1
Star Strider
Star Strider 2020년 4월 27일
The ‘T_c’ variable does not appear to exist.

답변 (1개)

Mehmed Saad
Mehmed Saad 2020년 4월 27일
I am amusing that T_c is an 11x11 matrix.
see this line of code
suppose i=11 and j=2
T(i,j) = (T_c(i-1,j) + T_c(i+1,j))/4 + T_c(i,j-1)/2;
You are trying to access i-1 index, i+1 index and i index of array T_c. as your array T_c has dimension 11x11. when you try to access row index i-1 which is 11-1 = 10, T_c gives you value but when you try to access row index i+1, which is 11+1 = 12, T_c gives error because no value exist at 12th row (matrix is 11x11)
  댓글 수: 1
Mehmed Saad
Mehmed Saad 2020년 4월 27일
either remove i+1 condition from Nth index and j+1 condition from Mth index (if that exist)
or add 12th row and column of zero (not recommended)

이 질문은 마감되었습니다.

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by