How can delete a variable within a netcdf file

조회 수: 35 (최근 30일)
Monica
Monica 2013년 10월 30일
답변: Monica 2013년 10월 31일
hello all, I have a problem, I need to delete a variable from a file with *. nc ... I've only found a command to delete file attributes within ... but the entire variable, not ... To delete an attribute is used netcdf.delAtt .... if someone could help me?
thank you very much Monica

채택된 답변

Kelly Kearney
Kelly Kearney 2013년 10월 30일
Not a Matlab solution, but if you have access to NCO ( http://nco.sourceforge.net/), issued from a terminal window:
ncks -x -v varname in.nc out.nc
or within Matlab:
system('ncks -x -v varname in.nc out.nc')

추가 답변 (2개)

Ashish Uthama
Ashish Uthama 2013년 10월 30일
"Attributes are more dynamic than variables or dimensions; they can be deleted and have their type, length, and values changed after they are created, whereas the netCDF interface provides no way to delete a variable or to change its type or shape." - http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.html
The only way would be to copy over everything, but the variable you want to delete, to a new file.

Monica
Monica 2013년 10월 31일
hello, thanks for your answers. At the end of the file have not deleted, I have overwritten .. changing step by step attributes, data, names and dimensions ...

카테고리

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