Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.




CDF MATLAB® Intro

Introduction

Mathworks MATLAB installation supports reading and writing CDF data files with two sources of CDF API’s. The “original”, provided with the standard MATLAB installation and the “SPDF Patch” version provided by the SPDF. The SPDF strongly recommends that CDF users install the SPDF Patch version as it will contain the features available in the latest release of the CDF library.

  1. The original set of routines which is included with MATLAB from MathWorks. There are several major modules and a package, namely:

    cdflib cdfread cdfwrite cdfinfo cdfepoch

    use MATLAB’s help command to see each module/package’s help information

    cdflib - a package that contains a set of functions, which provides low-level access to CDF files.

    cdfread - a CDF read module.

    cdfwrite - a CDF write module.

    cdfinfo - a module to get details about a CDF.

    cdfepoch - a module to construct CDF epoch, in CDF_EPOCH value or date-time string form, to a MATLAB epoch object. ** Not recommended **

  2. SPDF patch available from the SPDF’s CDF site at http://cdf.gsfc.nasa.gov

    The patch includes modules that are developed by SPDF. Note: Currently, to create a CDF with variables with data types CDF_TIME_TT2000 or CDF_INT8, users can only use the CDF write module from the SPDF patch, not from MATLAB’s module/package. However, MATLAB’s read module can read the data of those two data types from a CDF.

    All module names are preceded with “spdf”. Use the help command to view each module’s help information.

    These are the modules (some modules might work similarly to MATLAB’s):

    spdfbreakdownepoch16 - a module to break down CDF epoch time(s) in CDF_EPOCH16 data type into a date/time componment form. The value, a MATLAB’s complex, is from 0AD in picoseconds resolution.

    spdfbreakdownepoch - a module to break down CDF epoch time(s) in CDF_EPOCH data type into a date/time componment form. The time, a MATLAB’s double, is from 0AD in milliseconds resolution.

    spdfbreakdowntt2000 - a module to break down CDF epoch time(s) in CDF_TIME_TT2000 data type into a date/time componment form. The time, a MATLAB’s int64, is from J2000 in nanoseconds resolution with leap seconds.

    spdfcdfinfo - a module to get details about a CDF

    spdfcdfleapsecondsinfo - a module to display the leap seconds information.

    spdfcdfread - a CDF read module.

    spdfcdfupdate - a CDF update module.

    spdfcdfwrite - a CDF write module.

    spdfcomputeepoch16 - a module to compute the CDF epoch time(s) in CDF_EPOCH16 data type from a date/time componment form.

    spdfcomputeepoch - a module to compute the CDF epoch time(s) in CDF_EPOCH data type from a date/time componment form.

    spdfcomputett2000 - a module to compute the CDF epoch time(s) in CDF_TIME_TT2000 data type from a date/time componment form.

    spdfdatenumtoepoch16 - a module to convert MATLAB’s datenum to CDF epoch time(s) in CDF_EPOCH16 data type.

    spdfdatenumtoepoch - a module to convert MATLAB’s datenum to CDF epoch time(s) in CDF_EPOCH data type.

    spdfdatenumtott2000 - a module to convert MATLAB’s datenum to CDF epoch time(s) in CDF_TIME_TT2000 data type.

    spdfencodeepoch16 - a module to encode the CDF epoch time(s) in CDF_EPOCH16 data type to a date/time string form.

    spdfencodeepoch - a module to encode the CDF epoch time(s) in CDF_EPOCH data type to a date/time string form.

    spdfencodett2000 - a module to encode the CDF epoch time(s) in CDF_TIME_TT2000 data type to a date/time string form.

    spdfepoch16todatenum - a module to convert the CDF epoch time(s) in CDF_EPOCH16 data type to MATLAB’s datenum object.

    spdfepoch16unixtime - a module to convert the CDF epoch time(s) in CDF_EPOCH16 data type to Unix time(s).

    spdfepochtodatenum - a module to convert the CDF epoch time(s) in CDF_EPOCH data type to MATLAB’s datenum object.

    spdfepochunixtime - a module to convert the CDF epoch time(s) in CDF_EPOCH data type to Unix time(s).

    spdfparseepoch16 - a module to parse the CDF epoch time(s) in date/time string form to CDF_EPOCH16 data type.

    spdfparseepoch - a module to parse the CDF epoch time(s) in date/time string form to CDF_EPOCH data type.

    spdfparsett2000 - a module to parse the CDF epoch time(s) in date/time string form to CDF_TIME_TT2000 data type.

    spdftt2000todatenum - a module to convert the CDF epoch time(s) in CDF_TIME_TT2000 data type to MATLAB’s datenum object.

    spdftt2000unixtime - a module to convert the CDF epoch time(s) in CDF_TIME_TT2000 data type to Unix time(s).

To learn more about CDF’s use with MATLAB, please refer to the CDF MATLAB Quickstart Guide | Patch Notes