Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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

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

29-Mar-2010

Read an attribute associated with a variable.

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

    1.8000

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?