Global Index (short | long) | Local contents | Local Index (short | long)
Repeat for cold.nc
This script calls | |
---|---|
filin = ['warm.nc']; nc = netcdf(filin, 'write'); time = nc{'time'}(:); timunit = nc{'time'}.units(:); date = nc{'date'}(:); nbdate = nc{'nbdate'}(:); nbsec = nc{'nbsec'}(:); ndbase = nc{'ndbase'}(:); nsbase = nc{'nsbase'}(:); datesec = nc{'datesec'}(:); timenew = [14; 45; 76; 105; 135]; timunitnew = ['days since 0000-11-01 00:00:00\0']; datenew = [19971115 199712016 19980116 19980214 19980316]; nbdatenew = 19971101; nc{'time'}(:) = timenew; nc{'date'}(:) = datenew; nc{'nbdate'}(:) = nbdatenew; nc = close(nc); fid = ncmex('OPEN', filin, 'NC_WRITE'); [datatype, len, status] = ncmex('ATTINQ', fid, 'time', 'units'); status = ncmex('ATTPUT', fid, 'time', 'units', datatype, len, timunitnew); fid = ncmex('CLOSE', fid); filin = ['cold.nc']; nc = netcdf(filin, 'write'); time = nc{'time'}(:); timunit = nc{'time'}.units(:); date = nc{'date'}(:); nbdate = nc{'nbdate'}(:); nbsec = nc{'nbsec'}(:); ndbase = nc{'ndbase'}(:); nsbase = nc{'nsbase'}(:); datesec = nc{'datesec'}(:); timenew = [14; 45; 76; 105; 135]; timunitnew = ['days since 0000-11-01 00:00:00\0']; datenew = [19961115 199612016 19970116 19970214 19970316]; nbdatenew = 19961101; nc{'time'}(:) = timenew; nc{'date'}(:) = datenew; nc{'nbdate'}(:) = nbdatenew; nc = close(nc); fid = ncmex('OPEN', filin, 'NC_WRITE'); [datatype, len, status] = ncmex('ATTINQ', fid, 'time', 'units'); status = ncmex('ATTPUT', fid, 'time', 'units', datatype, len, timunitnew); fid = ncmex('CLOSE', fid); % Store and retrieve NetCDF attribute data: (always a row vector) % f.myGlobalAttribute(i) = myGlobalAttributeData % g(i) = myGlobalAttributeData % f{'myVariable'}.myAttribute(i) = myAttributeData % v.myAttribute(i) = myAttributeData % a(i) = myAttributeData % myGlobalAttributeData = f.myGlobalAttribute(i) % myGlobalAttributeData = g(i) % myAttributeData = f{'myVariable'}.myAttribute(i) % myAttributeData = v.myAttribute(i) % myAttributeData = a(i) % EXCEPTION: v.FillValue_ references the "_FillValue" attribute. % Use the "fillval(v, ...)" method to avoid confusion.