cdflib.deleteVar
Delete variable
Syntax
cdflib.deleteVar(cdfId,varNum)
Description
cdflib.deleteVar(cdfId,varNum)
deletes
a variable from a Common Data Format (CDF) file.
cdfId
identifies the CDF file. varNum
is
a numeric value that specifies the variable. Variable numbers are
zero-based.
Examples
Create a CDF, create a variable in the CDF, and then delete it.
cdfId = cdflib.create("your_file.cdf"); % Initially the file contains no variables info = cdflib.inquire(cdfId)
info = struct with fields: encoding: 'IBMPC_ENCODING' majority: 'ROW_MAJOR' maxRec: -1 numVars: 0 numvAttrs: 0 numgAttrs: 0
% Create a variable in the file varNum = cdflib.createVar(cdfId,"Time","cdf_int1",1,[],true,[]); % Retrieve info about the variable in the CDF varInfo = cdflib.inquireVar(cdfId,varNum)
varInfo = struct with fields: name: 'Time' datatype: 'cdf_int1' numElements: 1 dims: [] recVariance: 1 dimVariance: []
% Delete the variable from the file cdflib.deleteVar(cdfId,varNum) % Check to see if the variable was deleted from the file info = cdflib.inquire(cdfId)
info = struct with fields: encoding: 'IBMPC_ENCODING' majority: 'ROW_MAJOR' maxRec: -1 numVars: 0 numvAttrs: 0 numgAttrs: 0
% Clean up cdflib.delete(cdfId) clear cdfId
Tips
This function corresponds to the CDF library C API routine
CDFdeletezVar
.To use this function, you must be familiar with the CDF C interface. You can access the CDF documentation at the CDF website.