matlab中NetCDF文件相關函數

matlab中的幫助文檔:NetCDF Files

matlab提供了高層的函數來操作NetCDF,當然也提供了底層的函數接口,一般而言,用高層的接口就足夠了

高層函數

nccreate Create variable in NetCDF file(在NetCDF文件中創建變量)
ncdisp Display contents of NetCDF data source in Command Window(顯示內容)
ncinfo Return information about NetCDF data source(獲取文件的信息)
ncread Read data from variable in NetCDF data source(讀取變量)
ncreadatt Read attribute value from NetCDF data source(讀取屬性)
ncwrite Write data to NetCDF file(寫nc文件)
ncwriteatt Write attribute to NetCDF file(寫nc文件的屬性)
ncwriteschema Add NetCDF schema definitions to NetCDF file

簡單的使用可以參考這裏:用matlab讀取測高衛星jason2的netCDF格式數據的簡單示例(一)

底層函數

底層函數就是NetCDF庫的接口:

netcdf Interact directly with NetCDF Library

底層的函數就比較多了,可以點擊上面的鏈接查詢。

一個簡單的示例:

ncid = netcdf.open('text.nc'); % 打開nc文件
[ndims,nvars,ngatts,unlimdimid] = netcdf.inq(ncid); % 獲取文件相關信息
fmt = netcdf.inqFormat(ncid);  % 獲取文件格式

varid = netcdf.inqVarID(ncid, 'valname'); % 獲取變量'valname'的ID
val = netcdf.getVar(ncid, varid); % 通過ID獲得變量'valname'的值

netcdf.close(ncid); % 文件使用完要關閉
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章