MATLAB: Do I get this error

MATLABnetcdf

>> filename = 'out_pr_1899.nc'
filename =
'out_pr_1899.nc'
>> pr=ncread(filename,'Precipitation Rate')
Error using internal.matlab.imagesci.nc/openToRead (line 1272)
Could not open out_pr_1899.nc for reading.
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncread (line 61)
ncObj = internal.matlab.imagesci.nc(ncFile);

Best Answer

I just noticed a complication that the calendar for that "hours since" is in terms of 360 days per year. However I also notice that you do not ask for anything closer than yyyymmdd which happens to have a separate variable.
Experiment with:
yyyymmdd = ncread(filename, 'yyyymmdd');
if size(yyyymmdd,1) > size(yyyymmdd,2); yyyymmdd = yyyymmdd .'; end
xdates = datetime(cellstr(yyyymmdd), 'InputFormat', 'uuuuMMdd', 'format', 'yyyyMMdd');
At that point, please check whether
numel(xdates) == numel(unique(xdates))
because if they do not, then we need to include some time information so that there are no duplicate date entries.
If there are no duplicates, then you can use xdates directly as the x coordinates for plot(), unless you are using a version of MATLAB that is too old to support that.