matlab线性度计算程序
环境
matlab2023a
ads2020
原理
其中f(v)是曲线,fmax是f(v)的最大值,fmin是f(v)的最小值,vmax为fmax对应v值,vmin为fmin对应v值。
L=∆fmax/(fmax-fmin) (1)
∆fmax=max[f(v)-[fmin-K*(v-vmin)]] (2)
K=(fmax-fmin)/(vmax-vmin) (3)
代码
data1=importdata('schematic24.txt');%改变输入的文件名,文件数据的格式不一致需要自己调节
data2=data1.data;
vt=data2(:,1); %X轴的数据 若不要前十个数据==》vt=data2(10:end,1); 若全部==》改为 vt=data2(:,1);
freq=data2(:,2); %Y轴的数据 若不要前十个数据==》freq=data2(10:end,2); 若全部==》改为 freq=data2(:,2);
vt1=min(vt):0.05:max(vt);
freq1=interp1(vt,freq,vt1,"linear");
K=(max(freq1)-min(freq1))/(max(vt1)-min(vt1));
DeltaFreq=abs(freq1-(min(freq1)+K.*(vt1-min(vt1))));
DeltaFreqMax=max(DeltaFreq);
L=DeltaFreqMax/(max(freq1)-min(freq1));%线性度
IdealCurve=(min(freq1)+K.*(vt1-min(vt1)));
plot(vt1,freq1,vt1,IdealCurve);
xlabel("Vt(V)");
ylabel("F(GHz)");
RelativeBandwidth=(max(freq1)-min(freq1))/(max(freq1)+min(freq1))*2;
输入数据
ads导出的Vt-f数据
Vt f
4.00000000000000000E0 9.94315915744877721E-1
4.25000000000000000E0 1.01493151204090859E0
4.50000000000000000E0 1.03422490807067180E0
4.75000000000000000E0 1.05164280768404428E0
5.00000000000000000E0 1.06777990432062753E0
5.25000000000000000E0 1.08310328336644468E0
5.50000000000000000E0 1.09770768003155950E0
5.75000000000000000E0 1.11172932575729133E0
6.00000000000000000E0 1.12531380108596224E0
6.25000000000000000E0 1.13860792898479035E0
6.50000000000000000E0 1.15175718538421945E0
6.75000000000000000E0 1.16490578392067912E0
7.00000000000000000E0 1.17819886343963476E0
7.25000000000000000E0 1.19178584077378091E0
7.50000000000000000E0 1.20582289238475937E0
7.75000000000000000E0 1.22047052795578836E0
8.00000000000000000E0 1.23587824306338967E0
8.25000000000000000E0 1.25213803071271568E0
8.50000000000000000E0 1.26913562979576611E0
8.75000000000000000E0 1.28555359654201840E0
9.00000000000000000E0 1.30713158672056151E0
9.25000000000000000E0 1.32704294998017724E0
9.50000000000000000E0 1.34599061749011306E0
9.75000000000000000E0 1.36427848181836309E0
1.00000000000000000E1 1.38159593690375027E0
结果
可以看到线性度为4.29%。