%% Read from NetCDF File
% Open the sample NetCDF file, example.nc with read-only access,  read a variable, and then close the file. The netcdf.open function returns a file identifier.

ncid = netcdf.open('example.nc')

% Read the data associated with the variable, avagadros_number, in the example file, using the netcdf.getVar function. The second input to netcdf.getVar is the variable ID, which is a zero-based index that identifies the variable. The avagadros_number variable has the index value 0.

A_number = netcdf.getVar(ncid,0)

% Close the NetCDF file.

netcdf.close(ncid)

% Copyright 2018 The MathWorks, Inc.