Interpolation with multiple intersection points

조회 수: 17 (최근 30일)
Thijs van de Wiel
Thijs van de Wiel 2018년 1월 15일
댓글: Thijs van de Wiel 2018년 1월 16일
I have phase data from a bode plot. I want to interpolate this data and find the frequency where phase equals -135 deg.
Example:
f=[0.1 1 10 100 1000];
phase=[-90 -140 -80 -130 -180];
interp1(phase,f,-135)
ans =
50.5000
Clearly this is not the correct answer. To start there are 3 intersection points as shown by:
I am especially interested in the last intersection point around 200Hz. Is the use of interp1 incorrect in this case? Can somebody easily solve this issue. Only solution I see is using the find function and defining the intersection point as a range.

채택된 답변

John D'Errico
John D'Errico 2018년 1월 15일
편집: John D'Errico 2018년 1월 15일
Interp1 is defined for functions that have a SINGLE y value for any x. Since you are trying to call it for frequency as a function of phase, that clearly fails to be true. interp1 simply is not applicable to multi-valued relationships.
You have two simple options.
1. Just find the pairs of points that cross your line of interest. Use Linear interpolation, to locate the intersection. With so few points on a relationship that is so ill-defined, linear interpolation is the best you can ask for.
2. Download a code like Doug Schwarz's intersections code. Find it on the file exchange . It will generate all three intersections. Again, it will do only linear interpolation. You pass it two curves as sets of points. One of the curves will be simply the (red) straight line at a constant phase, given two frequencies.
[fint,phaseint] = intersections(f,phase,[.1 1000],[-135 -135])
fint =
0.91
1.75
190
phaseint =
-135
-135
-135
Although, since you are plotting this on a log axis, a log-linear interpolant might be better.
[fint,phaseint] = intersections(log10(f),phase,log10([.1 1000]),[-135 -135])
fint =
-0.1
0.083333
2.1
phaseint =
-135
-135
-135
fint = 10.^fint
fint =
0.79433
1.2115
125.89
So the former case will give you the green interpolant, the latter the blue interpolant.
  댓글 수: 1
Thijs van de Wiel
Thijs van de Wiel 2018년 1월 16일
Thank you for this solution, I am using Doug Schwarz's intersection code now.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2018년 1월 15일
편집: Matt J 2018년 1월 15일
interp1( phase(3:5) ,f(3:5), -135)
  댓글 수: 1
Thijs van de Wiel
Thijs van de Wiel 2018년 1월 16일
This is a solution, however quite one-sided and generally not applicable for varying phase signals.

댓글을 달려면 로그인하십시오.

카테고리

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