MATLAB: Interpolation 1-D

interpolation

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

Best Answer

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