error using start and count vectors

9 Ansichten (letzte 30 Tage)
Candice Cooper
Candice Cooper am 25 Mai 2021
Kommentiert: BN am 7 Nov. 2022
first I've opened a netcdf file. there are 8640 longitude points and 4320 latitude points. it is a world map. I'm trying to map a specific region. I created start and count vectors, then tried to extract the bio data corresponding to those lats and lons. However, I get an error, and can't figure out why.
% make the start and count vectors
start = [1440 1248 1]; % longitude -120.0208, latitude 38.0208
count = [7321 1320 1]; % longitude 125.0208, latitude 35.0208
fld = ncread(url,'bio',start,count);
This is the error I get:
Error using matlab.internal.imagesci.netcdflib
The NetCDF library encountered an error during execution of
'getVarsFloat' function - 'Index exceeds dimension bound
(NC_EINVALCOORDS)'.
Error in netcdf.getVar (line 182)
data =
matlab.internal.imagesci.netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/read (line 637)
data = netcdf.getVar(gid, varid, ...
Error in ncread (line 66)
vardata = ncObj.read(varName, varargin{:});
  1 Kommentar
BN
BN am 7 Nov. 2022
Dear @Candice Cooper did you find any solution for this? I have a same problem. Thank you

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Hrishikesh Borate
Hrishikesh Borate am 28 Mai 2021
Hi,
It’s my understanding that you are trying to make a map of a specific region from the world map. The ncread function reads data by beginning at the location specified in start. The count argument specifies the number of elements to be read along each dimension. As the start(1) + count(1) exceeds the number of points, ie., 1440+7321 = 8761, which is greater than 8640 points, you are facing the error.
For more information, refer to ncread.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by