% 读取NC文件中的降水数据 data = ncread('C:\grads\air.2m.mon.mean.nc', 'air');

% 提取时间范围为1979-2022年的数据 start_year = 1979; end_year = 2022; data = data(:, :, (start_year-1948)*12+1 : (end_year-1948+1)*12);

% 计算每个月的平均值 monthly_mean = mean(data, [1 2]);

% 计算每个月的变化量 monthly_change = diff(monthly_mean);

% 计算每个月的趋势 t = 1:length(monthly_mean); trend = polyfit(t, monthly_mean, 1);

% 绘制结果 figure; subplot(2, 1, 1); plot(monthly_change, 'b');

% 添加标题和标签 title('Monthly precipitation change'); xlabel('Month'); ylabel('Precipitation change (mm)');

subplot(2, 1, 2); plot(t, monthly_mean, 'b', t, trend(1)*t+trend(2), 'r');

% 添加标题和标签 title('Monthly precipitation trend'); xlabel('Month'); ylabel('Precipitation (mm)'); legend('Monthly precipitation', 'Trend line');

Matlab代码:从NC文件读取降水数据并分析月度变化趋势

原文地址: https://www.cveoy.top/t/topic/nm4z 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录