Skip to content

Commit

Permalink
Merge pull request #262 from NASA-Openscapes/cwannaz-patch-1
Browse files Browse the repository at this point in the history
Update read_data.qmd: added MATLAB code for netCDF
  • Loading branch information
jules32 authored Nov 14, 2023
2 parents d7ffd37 + a1dcdbe commit 4067026
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions how-tos/read_data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,30 @@ R code coming soon!
# Coming soon!
```

## Matlab
## MATLAB

Matlab code coming soon!
MATLAB provides [graphical import tools and two programmatic interfaces](https://www.mathworks.com/help/matlab/network-common-data-form.html) for interacting with netCDF files.

The high-level interface is made of eight high-level functions for getting information about netCDF files and their content, creating variables, writing and reading variables and attributes, and adding schema definitions to netCDF files.

```bash
#| echo: true
# Coming soon!
filename = "example.nc";
ncdisp(filename); % Display file content
varname = "peaks";
peaksData = ncread(filename,varname);
surf(peaksData);
```


The low-level interface is a thin wrapper around the underlying netCDF C library.
```bash
filename = "example.nc";
varname = "peaks";
ncid = netcdf.open(filename,"NC_NOWRITE");
varid = netcdf.inqVarID(ncid,varname);
peaksData = netcdf.getVar(ncid,varid);
netcdf.close(ncid)
surf(peaksData);
```

:::

Expand Down

0 comments on commit 4067026

Please sign in to comment.