Interpolation with multiple intersection points

16 ビュー (過去 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 Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by