How do I use "netcdf.getVar" to read a part of a variable?

9 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2018 年 5 月 22 日
編集済み: MathWorks Support Team 2023 年 6 月 1 日
I have an NC file with a large matrix in it. I would like to read only a portion of that matrix into memory for my calculation. How can I do this?

採用された回答

MathWorks Support Team
MathWorks Support Team 2023 年 6 月 1 日
編集済み: MathWorks Support Team 2023 年 6 月 1 日
First, the best way to easily improve efficiency in NETCDF I/O operations is to use the low level library in MATLAB. You can find documentation on that here: 
Essentially, the system works as described in the attached "exampleNETCDF.m" file. 
In order to read a portion of the variable, you need to
1. open the file
2. get the variable ID
3. use "netcdf.getVar" with the appropriate starting row/column and number of rows/columns
4. close the file
The syntax for "netcdf.getVar" is as such:
>> data = netcdf.getVar(ncid,varid,start,count)start = [startRow-1, startCol-1]
because MATLAB is 1-indexed and NETCDF is 0-indexed.
count = [numRows, numCols]

その他の回答 (0 件)

製品


リリース

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by