| Contents | Index |
netcdf.renameVar(ncid,varid,newName)
netcdf.renameVar(ncid,varid,newName) renames the variable identified by varid in the netCDF file identified by ncid.newName is a character string specifying the new name.
This function corresponds to the nc_rename_var function in the netCDF library C API. To use this function, you should be familiar with the netCDF programming paradigm. See netcdf for more information.
This example modifies a local copy of the example netCDF file included with MATLAB, example.nc.
% Open netCDF file.
ncid = netcdf.open('my_example.nc','NC_WRITE')
% Put file in define mode.
netcdf.redef(ncid)
% Get name of first variable
[varname, xtype, varDimIDs, varAtts] = netcdf.inqVar(ncid,0);
varname
varname =
avagadros_number
% Rename the variable, using a capital letter to start the name.
netcdf.renameVar(ncid,0,'Avagadros_number')
% Verify that the name of the variable changed.
[varname, xtype, varDimIDs, varAtts] = netcdf.inqVar(ncid,0);
varname
varname =
Avagadros_number
netCDF.defVar | netCDF.inqVar | netCDF.putVar

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |