Error 'Array indices must be positive integers or logical values.' when the number of indices is large

조회 수: 1 (최근 30일)
Hi all,
I have two vectors:
  • p of size 32x1,
  • b of size 300000x1. Value range of elements of b is [1, 32].
I want to assign
a = p(b)
And I got error: Array indices must be positive integers or logical values.
It was fine when I tried
a = p(b(1:40000)
However, MATLAB releases the error again with
a = p(b(1:50000)
Do you have any ideas on what problem that I encounted? Any help you have to offer would be greatly appreciated.

채택된 답변

madhan ravi
madhan ravi 2020년 8월 5일
편집: madhan ravi 2020년 8월 5일
In this case it’s probable that b has elements less than 1 and greater than 32.
Outside_bounds = nnz((b < 1) | (b > 32)) % to check
  댓글 수: 1
Soan Duong
Soan Duong 2020년 8월 5일
Thanks @madhan for your comment.
Yes, there are some elements of b equal to 0.
I have fixed the problem and it works now.

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

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by