netcdf.renameAtt
netCDF 属性の名前を変更する
構文
netcdf.renameAtt(ncid,varid,oldName,newName)
説明
netcdf.renameAtt(ncid,varid,oldName,newName)
は、oldName
で指定した属性の名前を、newName
で指定した名前に変更します。
oldName
と newName
は、文字ベクトルまたは string スカラーとして指定します。
ncid
は、関数 netcdf.create
または関数 netcdf.open
によって返される netCDF ファイル識別子です。
varid
は属性が関連付けられている変数を識別します。グローバル属性を指定するには、varid
に対して netcdf.getConstant('NC_GLOBAL')
を使用します。
この関数は、NetCDF ライブラリ C API の関数 nc_rename_att
に相当します。この関数を使用するには、NetCDF プログラミング パラダイムに関する知識が必要です。
例
この例では、MATLAB® に含まれている netCDF サンプル ファイル example.nc
のローカル コピーを変更します。
% Open netCDF file. ncid = netcdf.open('my_example.nc','NC_WRITE') % Get the ID of a variable the attribute is associated with. varID = netcdf.inqVarID(ncid,'avagadros_number') % Rename the attribute. netcdf.renameAtt(ncid,varID,'description','Description'); % Verify that the name changed. attname = netcdf.inqAttName(ncid,varID,0) attname = Description