%自动测量
x=(1:5)';
X=[ones(5,1) x];
Y=[24.2 35.6 46.8 58.8 71.0]';
[b,bint,r,rint,stats]=regress(Y,X);
z=b(1)+b(2)*x;
plot(x,Y,'ko',x,z,'r')
txt2 = ['拟合系数a为:' num2str(b(1)) ];
txt3 = ['拟合系数b为:' num2str(b(2)) ];
text(1.3,74.5,txt2);
text(1.3,71,txt3);
grid on
title("自动测量:IA-VG2K拟合曲线")
xlabel("n(谷点的序号)")
ylabel("电压VG2K(IA_min)")
%手动测量
n=(1:82)';
m=[0 0 0 0 0 0 0 0 0 0 0 1 6 10 14 18 20 22 23 24 23 20 17 15 16 20 27 33 38 40 39 35 29 22 16 13 18 29 42 53 58 60 56 48 38 26 18 17 27 45 61 75 82 83 77 68 55 40 30 28 40 59 79 91 106 109 105 96 83 67 55 51 60 76 97 116 130 138 140 135 124 110]';
plot(n,m,'ko',...
'LineWidth',1,...
'MarkerSize',5,...
'MarkerEdgeColor','w',...
'MarkerFaceColor',[0.5,0.5,0.5]);
hold on;
plot(n,m,'r');
grid on
xlabel("电压VG2K(V)")
ylabel("电流IA(10-7A)")
title("IA-VG2K曲线")
绘制出的拟合曲线如下图所示: