Error reading NetCDF files

Hello! I'm trying to read a NetCDF file using this:
f='global.nc';
fid=fopen(f,'r');
Temp=ncread(f,'t');
U=ncread(f,'u');
but it shows an error message, something like this:
Error using netcdflib
The NetCDF library encountered an error during execution of 'inqFormat' function - 'Not a valid ID
(NC_EBADID)'.
Error in netcdf.inqFormat (line 29)
fmt = netcdflib('inqFormat',ncid);
Error in internal.matlab.imagesci.nc/openToRead (line 1281)
this.Format = lower(netcdf.inqFormat(this.ncRootid));
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncread (line 53)
ncObj = internal.matlab.imagesci.nc(ncFile);
Any ideas of what is going wrong! Thank you!

7 comentarios

BN
BN el 13 de En. de 2020
Editada: BN el 13 de En. de 2020
Hey
can you show me this:
ncdisp(f)
results?
I think you want to open temperature and wind speed in this netcdf file.
filename = 'global.nc'
temp = ncread (filename,'t');
wind = ncread (filename, 'u');
Meg Noah
Meg Noah el 13 de En. de 2020
To list the variables:
filename = ('global.nc');
info = ncinfo(filename);
{info.Variables.Name}'
Thodoris Ptrks
Thodoris Ptrks el 13 de En. de 2020
neither ncinfo nor ncdisp work.. i think it's something with the library but i dont know..
BN
BN el 13 de En. de 2020
Editada: BN el 13 de En. de 2020
Dear Thodoris,
Please make sure the global.nc file exist in the current folder section of matlab:
Capture.JPG
after you sure about it try using this code below then show us what is the outputs:
filename='global.nc'; % exact Name of your netcdf file
ncdisp(filename)
also I want to know what is the version of your Matlab?
Thodoris Ptrks
Thodoris Ptrks el 13 de En. de 2020
yes i have set the direction folder from the beginning and imported the file... it crushes with ncdisp or ncread and all nc commands... i have 2018a version
BN
BN el 13 de En. de 2020
I think maybe your NetCDF file is corrupted. can you open the attached NetCDF file which I sent to you?
Thodoris Ptrks
Thodoris Ptrks el 13 de En. de 2020
no.. by the way thanks for your time..!

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Preguntada:

el 13 de En. de 2020

Comentada:

el 13 de En. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by