Cannot display/open NetCDF files - Please help!

18 views (last 30 days)
Hello,
Thank you very much for reading the question!
I have trouble reading my 31 nc files using ncdisp and netcdf.open. Here's my script:
folder='C:\xxx\';
liste=dir(folder);
for i=3:length(liste)
ncfile=liste(i).name;
% open nc
ncdisp(ncfile)
ncid=netcdf.open(ncfile);
end
It was working perfectly yesterday, but today it's not working for both ncdisp and netcdf.open after i switched directory folder to work on another m files. After i switched back to the right folder, the problem started. Here is the error message:
Error using internal.matlab.imagesci.nc/openToRead (line 1272)
Could not open 21413_20100615to20120713_qc.nc for reading.
% 21413_20100615to20120713_qc.nc is the first file i want to open
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncdisp (line 62)
ncObj = internal.matlab.imagesci.nc(ncFile);
If i turn off the ncdisp and run the netcdf.open, here is the error message:
Error using netcdf.open (line 52)
Could not open file '21413_20100615to20120713_qc.nc'.
Could someone please help me on this? I know it's not about the data because i redownload the same data and it's still stuck. My best shot will be redownloading the netcdf pack again, but i would really like to know the reason behind this. I am using matlab R2019b.
Thank you so much for your help!

Accepted Answer

Walter Roberson
Walter Roberson on 17 Mar 2020
ncfile = fullfile(folder, liste(i).name);
  2 Comments
ahamahoru
ahamahoru on 17 Mar 2020
It works! Thank you so much!
But what is happening here, why suddenly the previous script stops working after i changed the directory?
Walter Roberson
Walter Roberson on 17 Mar 2020
In order for the code to work you would have to have been cd to the folder.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!