Quantcast

Documentation Center

  • Trial Software
  • Product Updates

ncreadatt

Read attribute value from NetCDF data source

Syntax

attvalue = ncreadatt(source,location,attname)

Description

attvalue = ncreadatt(source,location,attname) reads the attribute attname from the group or variable specified by location in source, where source is the name of a NetCDF file or the URL of a NetCDF data source.

Input Arguments

source

Text string specifying the name of a NetCDF file or the URL of an OPeNDAP NetCDF data source.

location

Text string specifying a group or variable in the NetCDF data source. To read global attributes, set location to '/' (forward slash).

attname

Text string specifying the name of an attribute that you want to read in the NetCDF data source.

Output Arguments

attvalue

Data associated with the attribute.

Examples

Read a global attribute.

creation_date = ncreadatt('example.nc','/','creation_date');
disp(creation_date);
 

Read an attribute associated with a variable.

scale_factor = ncreadatt('example.nc','temperature','scale_factor');
disp(scale_factor);
 

Read an attribute associated with a group (netcdf4 format files only).

desc_value = ncreadatt('example.nc','/grid2','description');
disp(desc_value);

See Also

| | | |

Tutorials

Was this topic helpful?