Documentation

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('mycdf.cdf');

% Initially the file contains no variables.
info = cdflib.inquire(cdfid)

info = 

     encoding: 'IBMPC_ENCODING'
     majority: 'ROW_MAJOR'
       maxRec: -1
      numVars: 0
    numvAttrs: 0
    numgAttrs: 0

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

% Retrieve info about the variable in the CDF. 

info = cdflib.inquireVar(cdfid, 0)

info = 

           name: 'Time'
       datatype: 'cdf_int1'
    numElements: 1
           dims: []
    recVariance: 1
    dimVariance: []

% Delete the variable from the CDF

cdflib.deleteVar(cdfid,0);

% Check to see if the variable was deleted from the CDF.
info = cdflib.inquire(cdfid)

info = 

     encoding: 'IBMPC_ENCODING'
     majority: 'ROW_MAJOR'
       maxRec: -1
      numVars: 0
    numvAttrs: 0
    numgAttrs: 0

% Clean up
cdflib.delete(cdfid);

clear cdfid

References

This function corresponds to the CDF library C API routine CDFdeletezVar.

To use this function, 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.

Was this topic helpful?