函数
ncinfo
info = ncinfo('D:\DATA\data.nc'); %读取nc文件信息
ncread
nc_var = ncread('D:\DATA\data.nc','SIF'); %读取nc文件中‘SIF’变量,具体读取什么变量自己修改。
代码
第一步读取文件
Path = 'D:\DATA\'; % 设置路径,记得加上最后的反斜杠 File = dir(fullfile(Path,'*.nc')); % dir 函数读取.nc格式的文件名 'name' ,路径‘folder’ 等信息 Len = length(File); % 读取文件数量
第二步循环提取nc变量
for i = 1:Len full_path = strcat(Path,File(i).name); % 拼接路径和文件名,并显示 nc_var_sif(:,:,i) = ncread(full_path,'SIF'); % 提取nc文件中变量‘SIF’ end
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/200187.html原文链接:https://javaforall.net
