Skip to Main Content Skip to Search
Product Documentation

cdflib.renameVar - Rename existing variable

Syntax

cdflib.renameVar(cdfId,varNum,newName)

Description

cdflib.renameVar(cdfId,varNum,newName) renames a variable in a Common Data Format (CDF) file.

cdfId identifies the CDF file. varNum is a numeric value that identifies the variable. Variable numbers are zero-based. newName is a text string that specifies the name you want to assign to the variable.

Examples

Create a CDF, create a variable in the CDF, and then rename the variable. To run this example, you must be in a writable folder.

cdfid = cdflib.create('your_file.cdf');

% Create a variable in the file.
varNum = cdflib.createVar(cdfid,'Time','cdf_int1',1,[],true,[]);

% Get the name of the variable. 
name = cdflib.getVarName(cdfid,varNum)

name = 

Time

% Rename the variable
cdflib.renameVar(cdfid,varNum,'NewName');

% Check the new name.
name = cdflib.getVarName(cdfid,varNum)

name =

NewName

%  Clean up
cdflib.delete(cdfid)

clear cdfid

References

This function corresponds to the CDF library C API routine CDFrenamezVar. To use these functions, you must be familiar with the CDF C interface. Read the CDF documentation at the CDF Web site. For copyright information, see the cdfcopyright.txt file.

See Also

cdflib.createVar

Tutorials

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS