Error using sub2ind(line43)

조회 수: 1 (최근 30일)
Hao-Ming Peng
Hao-Ming Peng 2017년 4월 26일
댓글: Hao-Ming Peng 2017년 4월 26일
I have this code
idx = sub2ind(size(map),ygrid,xgrid)
It causes Error using sub2ind(line43) Out of range subscript.
But I check the subscripts: where size(map) gives
ans = 5 5
and
all(find(ygrid<=5 & ygrid>=1))
gives
ans = logical
1
and also
all(find(xgrid<=5 | xgrid>=1))
gives
ans = logical
1
It seems all of the subscripts I specified in ygrid and xgrid. So I don't know why the error happens.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 4월 26일
You tested
all(find(xgrid<=5 | xgrid>=1))
Your test should have been &
  댓글 수: 1
Hao-Ming Peng
Hao-Ming Peng 2017년 4월 26일
Oh! Thank you! I also find that I have to test it with
all(xgrid<=5 & xgrid>=1)

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

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by