Error to extract 4-D double nc data

조회 수: 6 (최근 30일)
Fatihah Shariful
Fatihah Shariful 2022년 8월 10일
답변: Pooja Kumari 2023년 9월 16일
Hello,
I am having trouble to extract nc data. it shows an error Index in position 1 exceeds array bounds. Index must
not exceed 1.
N=5088
sizelong=length(lon);
sizelat=length(lat);
for jj=1:sizelong;
idxlon(jj)=all(ismember(want1,lon(1:5088,:)));
idxlat(jj)=all(ismember(want2,lat(1:5088,:)));
end
rowId=find(idxlon);
colId=find(idxlat);
Please help.
  댓글 수: 2
KSSV
KSSV 2022년 8월 10일
What exactly you are trying?
Fatihah Shariful
Fatihah Shariful 2022년 8월 10일
I want to extract a data that consist of several variables from a coordinate.

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

답변 (1개)

Pooja Kumari
Pooja Kumari 2023년 9월 16일
Dear Fatihah,
I understand that you are facing “Index in position 1 exceeds array bounds. Index must not exceed 1” error while trying to extract 4-D nc Data. The error message suggests that there is an issue with the indexing of the arrays, it might be possible that the index values you are using are exceeding the array bounds. Here are the troubleshooting steps for your code :
  1. It might be possible that the issue will be with “idxlon” and “idxlat” arrays as all the column values are stored lon(1:5088,:) and these arrays are initialized inside the loop, which means their size are not predetermined.
  2. You can preallocate the “idxlon and “idxlat” arrays before the loop.
  3. There might be some issue while reading data variable in netCDF data source using “ncdata” function. You can refer to the below documentation for more information on “ncdata” function: https://www.mathworks.com/help/matlab/ref/ncread.html
  4. A similar workaround is given in the following MATLAB Answers you can refer: https://www.mathworks.com/matlabcentral/answers/1608670-how-to-process-nc-file-in-matlab
I hope this helps!

카테고리

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