Error to extract 4-D double nc data

3 Ansichten (letzte 30 Tage)
Fatihah Shariful
Fatihah Shariful am 10 Aug. 2022
Beantwortet: Pooja Kumari am 16 Sep. 2023
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 Kommentare
KSSV
KSSV am 10 Aug. 2022
What exactly you are trying?
Fatihah Shariful
Fatihah Shariful am 10 Aug. 2022
I want to extract a data that consist of several variables from a coordinate.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Pooja Kumari
Pooja Kumari am 16 Sep. 2023
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!

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by