This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Rachel, > I am using matlab to read in NetCDF data and it is very important that I > know what type of data type a particular variable is. I use the following > command: > > [varname, vartype, dimids, natts] = netcdf.inqVar(ncid,0) > > The 'vartype' variable gives me a number associated with a particular data > type (integer, byte, double, etc) but I cannot find the information about > which data types go along with which constant. Assuming Matlab uses the same constants as the netCDF C library, then here are the types, from the the netCDF C library documentation: http://www.unidata.ucar.edu/netcdf/docs/external_types.html They are also listed in the netcdf.h header file for the netCDF C library: /* * The netcdf external data types */ #define NC_NAT 0 /**< Not A Type */ #define NC_BYTE 1 /**< signed 1 byte integer */ #define NC_CHAR 2 /**< ISO/ASCII character */ #define NC_SHORT 3 /**< signed 2 byte integer */ #define NC_INT 4 /**< signed 4 byte integer */ #define NC_LONG NC_INT /**< deprecated, but required for backward compatibility. */ #define NC_FLOAT 5 /**< single precision floating point number */ #define NC_DOUBLE 6 /**< double precision floating point number */ #define NC_UBYTE 7 /**< unsigned 1 byte int */ #define NC_USHORT 8 /**< unsigned 2-byte int */ #define NC_UINT 9 /**< unsigned 4-byte int */ #define NC_INT64 10 /**< signed 8-byte int */ #define NC_UINT64 11 /**< unsigned 8-byte int */ #define NC_STRING 12 /**< string */ /* The following are use internally in support of user-defines * types. They are also the class returned by nc_inq_user_type. */ #define NC_VLEN 13 /**< vlen (variable-length) types */ #define NC_OPAQUE 14 /**< opaque types */ #define NC_ENUM 15 /**< enum types */ #define NC_COMPOUND 16 /**< compound types */ --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: UEC-670182 Department: Support netCDF Priority: Normal Status: Closed