Find intersection between two curves

28 ビュー (過去 30 日間)
Akash Gooljar
Akash Gooljar 2021 年 3 月 7 日
コメント済み: Torsten 2023 年 7 月 6 日
Hello i have plot two curves and i would like to create a function so as to find the intersections between the two curves
Here is my code :
x=-100*pi:pi/32:100*pi;
y1=exp(x);
y2=sin(x);
figure(1)
plot(y1,'b');hold on
plot(y2,'g');
hold off
grid

採用された回答

Jan
Jan 2021 年 3 月 7 日
編集済み: Jan 2021 年 3 月 7 日
The intersection is the location, where both functions have the same value. Then their difference is 0.
You can use fzero with the function: @(x) exp(x) - sin(x).
  8 件のコメント
ANA MARIA SANCHEZ GONZALEZ
ANA MARIA SANCHEZ GONZALEZ 2023 年 7 月 6 日
Hi guys! I need to find the intersection between two curves but one of them is given as vectors (experimental data). Could you please help me with that? Thank you in advance!
Torsten
Torsten 2023 年 7 月 6 日
Is interpolating the measurement data by a spline curve, taking the difference of the two so created curves and searching for a zero of this difference function an option ?
% Artificial measurement data
x = 0:0.1:2;
fi_measurement = x.^2;
% Second curve
f = @(x) x;
% Fit measurement data by spline curve
f_measurement = @(xq) interp1(x,fi_measurement,xq,'spline');
% Find intersection(s) between spline curve and second curve
sol1 = fzero(@(x)f(x)-f_measurement(x),0.5)
sol1 = -1.0469e-22
sol2 = fzero(@(x)f(x)-f_measurement(x),1.5)
sol2 = 1

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by