netcdf.renameVar - Change name of netCDF variable
Syntax
netcdf.renameVar(ncid,varid,newName)
Description
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 information about netCDF contained in the NetCDF
C Interface Guide for version 3.6.2.
Examples
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
See Also
netCDF.defVar, netCDF.inqVar, netCDF.putVar
 | netcdf.renameDim | | netcdf.setDefaultFormat |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit