netcdf.getVar vs ncread

15 ビュー (過去 30 日間)
oceanmod
oceanmod 2019 年 10 月 2 日
コメント済み: oceanmod 2019 年 10 月 2 日
The following command works:
ncread(ncfile,'some_variable',[1 1],[Inf 1]); % assuming ncfile is a netcdf file that exists and has the variable listed
It reads in an array as the 'Inf' value instructs Matlab to read all values along the first dimension.
The command below, however, fails:
netcdf.getVar(ncid,some_variable_id,[1 1],[Inf 1]) % ncid is the ID of ncfile (see previous line of code)
and I get an error message stating "Index arguments must be finite." How then does one use netcdf.getVar to read all values along a dimension?
PS: I have deleted an earlier related question that had some errors.

採用された回答

Walter Roberson
Walter Roberson 2019 年 10 月 2 日
You fetch the information about the variable and substitute in the known size instead of inf .
  1 件のコメント
oceanmod
oceanmod 2019 年 10 月 2 日
Thanks! I just decided to use ncread instead.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by