| Contents | Index |
cdflib.renameVar(cdfId,varNum,newName)
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.
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 cdfidThis 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.

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 |