使用“npole”参数与rationalfit
这个例子展示了如何使用'NPoles'参数来提高输出的质量rationalfit
.默认情况下,rationalfit
函数使用48个或更少的极点来找到与数据最匹配的有理函数。如果48个极点还不够,那么改变所使用的极点数量的范围可能是有利的rationalfit
.
首先,读入文件中包含的带通滤波器数据npoles_bandpass_example.s2p
,并绘制S21
数据。接下来,使用rationalfit
函数来拟合有理函数S21
数据,并将“NPoles”参数设置为默认值,并将结果与原始数据进行可视化比较。最后,使用rationalfit
同样,这一次指定更大数量的极点,看看结果是否有所改善。
读取和可视化数据
S =参数(“npoles_bandpass_example.s2p”);图subplot(2,1,1) rfplot(S,2,1,“数据库”) subplot(2,1,2) rfplot(S,2,1)“角”)
分析“NPoles”使用默认值时rationalfit的输出
使用rfparam
函数来提取S21
值,然后调用rationalfit
.
s21 = rfparam(S,2,1);datafreq = s。Defaultfit = rationalfit(datafreq,s21);
警告:48根杆子只能达到-13.0 dB的精度,而不是-40.0 dB。考虑使用'NPoles'参数指定更大数量的极点。
使用freqresp
函数来计算的输出的响应rationalfit
.
Respfreq = 2.25e9:2e5:2.75e9;Defaultresp = freqresp(defaultfit,respfreq);
将原始数据与默认有理函数的频响进行比较rationalfit
.
次要情节(2,1,1)情节(datafreq, 20 * log10 (abs (s21)),“。”)举行在情节(respfreq, 20 * log10 (abs (defaultresp)))从包含(的频率(赫兹)) ylabel (“(dB)级”) defaultnpoles =数字(defaultfit.A);Defaultstr = [默认npole (Uses)num2str (defaultnpoles),“两极)”];标题(defaultstr)传说(“原始数据”,“默认rationalfit”,“位置”,“最佳”) subplot(2,1,2) plot(datafreq,unwrap(角度(s21))*180/pi,“。”)举行在情节(respfreq打开(角(defaultresp)) * 180 / pi)从包含(的频率(赫兹)) ylabel (的角(度))传说(“原始数据”,“默认rationalfit”,“位置”,“最佳”)
分析的输出有多好rationalfit
匹配原始数据时,显示为rationalfit
在带通区域的中心做得比较好,在带通区域的边缘拟合较差。使用更复杂的有理函数可能会获得更好的拟合。
分析使用自定义值“npole”时rationalfit的输出
适合原装S21
数据,但这次是指令rationalfit
使用“NPoles”参数在49和60极点之间使用。
Customfit = rationalfit(datafreq,s21,“NPoles”60, [49]);Customresp =频率(customfit,respfreq);
将原始数据与自定义有理函数的频率响应进行比较rationalfit
.
图subplot(2,1,1) plot(datafreq,20*log10(abs(s21)),“。”)举行在情节(respfreq, 20 * log10 (abs (customresp)))从包含(的频率(赫兹)) ylabel (“(dB)级”) customnpoles =数字(customfit.A);Customstr = ['NPoles =[49 60](使用'num2str (customnpoles),“两极)”];标题(customstr)传说(“原始数据”,“自定义rationalfit”,“位置”,“最佳”) subplot(2,1,2) plot(datafreq,unwrap(角度(s21))*180/pi,“。”)举行在情节(respfreq打开(角(customresp)) * 180 / pi)从包含(的频率(赫兹)) ylabel (的角(度))传说(“原始数据”,“自定义rationalfit”,“位置”,“最佳”)
使用更大数量的杆子的拟合显然更精确。