How can I overwrite my NETCDF4 file in MATLAB?
3 views (last 30 days)
Show older comments
MathWorks Support Team
on 25 Oct 2013
Edited: MathWorks Support Team
on 25 Jan 2021
I am trying to create a NETCDF4 file using NETCDF.CREATE function in MALTAB. The documentation says that two modes can be used in combination by using a BITOR of their respective integers, but when I use CLOBBER mode along with NETCDF4 mode I still can't overwrite my file and MATLAB throws an error message.
Accepted Answer
MathWorks Support Team
on 25 Jan 2021
Edited: MathWorks Support Team
on 25 Jan 2021
This error occurs when the netCDF file was not closed before attempting to overwrite it. The file needs to be properly closed first using netcdf.close, before calling netcdf.create to overwrite it.
The following code snippet illustrates the correct way to proceed:
mode = netcdf.getConstant('CLOBBER');
mode = bitor(mode, netcdf.getConstant('NETCDF4'));
fileID = netcdf.create('file1.nc', mode);
netcdf.close(fileID);
fileID = netcdf.create('file1.nc', mode);
With this:
>> fileID
fileID =
65536
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!