Navigation : Top/MATLAB/netcdf toolboxの使い方

netcdf toolboxの使い方

netCDFデータを読む

  • 文法
    • nc = netcdf('path', 'mode')
    • nc -- The output "netcdf" object, or [] if error.
    • path -- The path (filename) as a string.
    • mode -- The string 'nowrite' or 'write'.
    • nc = netcdf('foo.nc', 'nowrite')

ファイルを閉じる

  • 文法
    • result = close(nc)

ファイルの情報を得る

  • 文法
    • theDims = dim(nc)
    • theVars = var(nc)
    • theGAtts = att(nc)
    • theRecdim = recdim(nc)
  • 内容
    • nc -- "netcdf" object.
    • theDims -- List of "ncdim" dimension objects.
    • theVars -- List of "ncvar" variable objects.
    • theGAtts -- List of "ncatt" global attribute objects.
    • theRecdim -- The "ncdim" record-dimension object.
    • nc = netcdf('foo.nc', 'write')
    • if isempty(nc), error(' ## Bad netcdf operation.'), end
    • theDims = dim(nc) % List of "ncdim" dimension objects.
    • theVars = var(nc) % List of "ncvar" variable objects.
    • theGAtts = att(nc) % List of "ncatt" global attribute objects.
    • theRecdim = recdim(nc) % The "ncdim" record-dimension object.

オブジェクトからデータを得る

  • 文法
    • theVar = nc{'theVarname'};
    • theVar = nc{'theVarname'}(:);
    • theVar = ncvar('theVarname', nc);
  • 内容
    • theVar -- The "ncvar" variable object.
    • nc -- The parent "netcdf" object.
    • theVarname -- The string-name of the variable.
    • theVar = nc{'elevation'}

データを書き込む

nc=netcdf(fname,'write'); nc{'h'}(:)=h; close(nc);