Interpolation 1-D

조회 수: 11 (최근 30일)
Shan  Chu
Shan Chu 2017년 6월 29일
댓글: John D'Errico 2017년 6월 29일
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

채택된 답변

John D'Errico
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
Shan  Chu
Shan Chu 2017년 6월 29일
Hi, First of all, I am sorry but I thought the interpolation function will help to define any point that follows the trend of the curve. I didn't know that the curve needs to be a single-valued function of the independent variables. Secondly, I just found that if I changed the method from spline to pchip, it will get the correct answer. I don't know how it works. If you know it, please enlighten me. Finally, thank you for answering and also introducing me your toolbox. It's very helpful. Thanks to David too. It's a rookie mistake.
John D'Errico
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 CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by