Index in position 1 is invalid. Array indices must be positive integers or logical values.

조회 수: 15 (최근 30일)
Hey all,
Long story short, I need to flip my data/reassign the w data to new indices on the y axis and got the indices 394,530. However I am trying to extract the data from ReSHEARLAYERandWAKE2(1).uxux.w (a structured data set containing some w values - say reynolds stresses for each x and y position)
from specific x and y ranges, and yet everytime i am shown an error "Index in position 1 is invalid. Array indices must be positive integers or logical values."
ww = ReSHEARLAYERandWAKE2(1).uxux.w;
wwmirror = ww;
for i = 0:366
for j = 394:530
wwmirror(i,1080 - (j - 394)) = ww(i,j)
end
end

채택된 답변

Bhaskar R
Bhaskar R 2020년 3월 11일
편집: Bhaskar R 2020년 3월 11일
Index of the array start from 1 and it must be positive integer in MATLAB.
In your code for loop i = 0:366 starting from 0 that means ww(i,j) iterates as w(0, 394) so on.. It is invalid in MATLAB indexing
so change the logic so that in satisfies "Index of the array start from 1 and it must be positive integer in MATLAB."
For more details
  댓글 수: 1
yashvini shukla
yashvini shukla 2020년 3월 11일
Thanks a lot!! That worked. I am triying to use the showf function, and it works
>> showf(ReSHEARLAYERandWAKE2(1).mean(223:400,100:500))
Index in position 1 exceeds array bounds (must not exceed 1).
not sure how to show only specific parts in the data.
thankss

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

추가 답변 (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