Documentation

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

collapse all

Read Global Attribute

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

29-Mar-2010

Read Attribute Associated with Variable

Read an attribute associated with a variable.

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

    1.8000

Read Attribute Associated with Group

Read an attribute associated with a group. This example applies to netcdf4 format files only.

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

This is another group attribute.

Related Examples

Introduced in R2011a

Was this topic helpful?