Interpolation 1-D
1 次查看(过去 30 天)
显示 更早的评论
Hi, I have a set of measured data s21_ef_d (i have included the mat file) Then I want to interpolate the 3dB cut off value but it seems like Matlab gave me the wrong anwser. Here is my code:
load('s21_ef_d.mat');
f=linspace(500e6,3e9,1601);
[a0_ef_d b0_ef_d]=max(20*log(abs(s21_ef_d)));
f01=interp1(20*log(abs(s21_ef_d)),f/1e9,(a0_ef_d-3),'spline');
Then Mtalab gave me f01=1.7521e+09 which should be only around 1.73e+09. Could anyone please help? Thanks
0 个评论
采纳的回答
John D'Errico
2017-6-29
编辑:John D'Errico
2017-6-29
NEVER just throw anything (without thought) into a numerical routine and expect intelligence to come out of it. What is the old saying, garbage in, garbage out?
plot(20*log(abs(s21_ef_d)),f/1e9,'.')
This is what you are trying to use interp1 on.
Does that curve represent a single valued function of the independent variable? The independent variable here is 20*log(abs(s21_ef_d)). NO! It is not single valued.
Interpolation will result in random junk.
Apparently you want to locate the points where the curve passes through (a0_ef_d-3). Since we have
a0_ef_d-3
ans =
-93.97
It looks like there will be two solutions.
The simplest way to compute those two locations is to use my slmsolve utility, applied to a spline formed from the data passed in in reverse order. slmsolve is part of my SLM toolbox. As it turns out, I wrote that tool to also work on the pp form splines as returned from spline or pchip.
spl = spline(f/1e9,20*log(abs(s21_ef_d)))
spl =
struct with fields:
form: 'pp'
breaks: [1×1601 double]
coefs: [1600×4 double]
pieces: 1600
order: 4
dim: 1
result = slmsolve(spl,a0_ef_d-3)
result =
1.6056 1.7314
plot(20*log(abs(s21_ef_d)),f/1e9,'b-')
hold on
plot(a0_ef_d-3,result','rs')
You can get the SLM tools here:
https://www.mathworks.com/matlabcentral/fileexchange/24443-slm-shape-language-modeling
3 个评论
John D'Errico
2017-6-29
No. PCHIP, applied to a non-single valued function as you have, will NOT give you a correct answer. It will just not give you quite as bad an answer. PCHIP also requires a single valued function.
I think both of those tools just sort your points on x, only then build a spline. But if you sort the data on x, it removes the essential nature of the curve.
So you need here to switch the axes, because really, the curve is single valued when viewed as x(y), thus x as a function of y. Even there, there will be two solutions to the inverse function.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Smoothing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!