Interpolation with multiple intersection points
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Thijs van de Wiel
il 15 Gen 2018
Commentato: Thijs van de Wiel
il 16 Gen 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.
0 Commenti
Risposta accettata
John D'Errico
il 15 Gen 2018
Modificato: John D'Errico
il 15 Gen 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.
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!