Error to extract 4-D double nc data
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
Antworten (1)
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 :
- 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.
- You can preallocate the “idxlon” and “idxlat” arrays before the loop.
- 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
- 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!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!