Intersection between the two curves

1 回表示 (過去 30 日間)
guru k
guru k 2019 年 8 月 29 日
コメント済み: Star Strider 2019 年 8 月 29 日
How to get the intersection between the two curves (Red Color & Blue Color) shown in figure above?
Any coding to get the point of intersection?
  3 件のコメント
Adam Danz
Adam Danz 2019 年 8 月 29 日
Star Strider
Star Strider 2019 年 8 月 29 日
guru k’s Answer moved here —
I have to find out the intersection between the two curve equations plotted above? I have given the plots.

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

回答 (1 件)

Star Strider
Star Strider 2019 年 8 月 29 日
This approximates your data and calculates and plots the intersections:
t = linspace(0, 1500, 250); % Independent Variable
f1 = 100*sin(2*pi*t/100); % First Curve
f2 = 10*sin(2*pi*t/100) - t*0.2; % Second Curve
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
df = f1 - f2;
fzx = zci(df);
for k = 2:numel(fzx)-1 % Interpolation Loop (Do Not Include First Or Last Values)
ixr = [fzx(k)-1 fzx(k)+1]; % Interpolation Index Range
tv = t(ixr);
dv = df(ixr);
B = [tv(:) [1; 1]] \ dv(:); % Estimate Parameters
ti(k) = -B(2) / B(1); % ‘t’ At Zero-Crossing
f1v(k) = interp1(tv, f1(ixr), ti(k)); % ‘f1’ At Intersection
f2v(k) = interp1(tv, f2(ixr), ti(k)); % ‘f2’ At Intersection
end
figure
plot(t, f1, t, f2) % Plot Curves
hold on
plot(ti, f1v, 'x', ti, f2v, '+') % Plot Intersections
hold off
grid

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by