필터 지우기
필터 지우기

problem editing specific variables in a netcdf file using ncwrite

조회 수: 7 (최근 30일)
I'm trying to edit values in a netcdf file using ncread and ncwrite. For example,
foo = ncread('myfile.nc','x')
Where foo is:
10×1 single column vector
1
2
3
9999
5
6
7
8
9
10
So I want to change the fourth element from 9999 to 4 and write the array back to my netcdf file.
foo(4) = 4
ncwrite('myfile.nc','x',foo)
However, I get the following error:
Error using netcdflib
The NetCDF library encountered an error during execution of 'open' function - 'HDF error (NC_EHDFERR)'.
Error in netcdf.open (line 59)
[varargout{:}] = netcdflib ( 'open', filename, varargin{1} );
Error in internal.matlab.imagesci.nc/openToAppend (line 1238)
this.ncRootid = netcdf.open(this.Filename,'WRITE');
Error in internal.matlab.imagesci.nc (line 123)
this.openToAppend();
Error in ncwrite (line 71)
ncObj = internal.matlab.imagesci.nc(ncFile,'a',formatStr);

채택된 답변

Zenin Easa Panthakkalakath
Zenin Easa Panthakkalakath 2019년 1월 21일
Hi Brice,
It appears to be that the NC file specified in the 'filename' variable is not editable. Use the file explorer to have a look into the properties of the file and check if it is 'Read Only'. Also, look into the security tab under properties and see if the current user has the privilege to Modify the file.
Regards,
Zenin

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by