实现效果:
clc; clear;
filename = 'sri.xlsx'; % 确认文件路径
data = readtable(filename);
datavalue = data{:,2:end};
datavalue = datavalue';
fig = figure('Position', [0, 0, 1500, 900]);
indexString = ["(a)","(b)","(c)","(d)","(e)","(f)","(g)",];
subplotName = ["h1","h2","h3","h4","h5","h6","h7"];
for i = 1:7
subplot(4,2,i);
years = datavalue(:,1);
values = datavalue(:,i+1);
coefficients = polyfit(years, values, 1);
k = coefficients(1);
b = coefficients(2);
% 计算Y轴上下限值,将其设置为最大值和最小值的 1.1 倍
y_max = max(values) * 1.3;
y_min = min(values) * 1.3;
plot(years, values, 'o