Main Content

cdflib.deleteVarRecords

Delete range of records from variable

Syntax

cdflib.deleteVarRecords(cdfId,varNum,startRec,endRec)

Description

cdflib.deleteVarRecords(cdfId,varNum,startRec,endRec) deletes a range of records from a variable in a Common Data Format (CDF) file.

Input Arguments

cdfId

Identifier of a CDF file, returned by a call to cdflib.create or cdflib.open.

varNum

Numeric value that identifies the variable. Variable numbers are zero-based.

startRec

Numeric value that specifies the record at which to start deleting records. Record numbers are zero-based.

endRec

Numeric value that specifies the record at which to stop deleting records. Record numbers are zero-based.

Examples

Make a writable copy of the example CDF, get the number of a variable in the CDF, and delete specific records in the variable. To run this example, you must be in a writable folder.

srcFile = fullfile(matlabroot,"toolbox","matlab","demos","example.cdf");
copyfile(srcFile,"myfile.cdf")
fileattrib("myfile.cdf","+w")

cdfId = cdflib.open("myfile.cdf");
varNum = cdflib.getVarNum(cdfId,"Temperature");

% Inspect records 1 and 3 of the variable
oldFirstRecord = cdflib.getVarRecordData(cdfId,varNum,1)
oldFirstRecord =

  2×3 int16 matrix

   1   1   1
   1   1   1
oldThirdRecord = cdflib.getVarRecordData(cdfId,varNum,3)
oldThirdRecord =

  2×3 int16 matrix

   3   3   3
   3   3   3
% Delete records 1 and 2 from the variable
cdflib.deleteVarRecords(cdfId,varNum,1,2)

% Check that the new record 1 is the old record 3
newFirstRecord = cdflib.getVarRecordData(cdfId,varNum,1)
newFirstRecord =

  2×3 int16 matrix

   3   3   3
   3   3   3
%Clean up
cdflib.delete(cdfId)
clear cdfId

References

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

To use this function, you must be familiar with the CDF C interface. You can access the CDF documentation at the CDF website.