Interpolation with multiple intersection points

18 Ansichten (letzte 30 Tage)
Thijs van de Wiel
Thijs van de Wiel am 15 Jan. 2018
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.

Akzeptierte Antwort

John D'Errico
John D'Errico am 15 Jan. 2018
Bearbeitet: John D'Errico am 15 Jan. 2018
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 Kommentar
Thijs van de Wiel
Thijs van de Wiel am 16 Jan. 2018
Thank you for this solution, I am using Doug Schwarz's intersection code now.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Matt J
Matt J am 15 Jan. 2018
Bearbeitet: Matt J am 15 Jan. 2018
interp1( phase(3:5) ,f(3:5), -135)
  1 Kommentar
Thijs van de Wiel
Thijs van de Wiel am 16 Jan. 2018
This is a solution, however quite one-sided and generally not applicable for varying phase signals.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by