Intersection between the two curves

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 Kommentare

James Tursa
James Tursa am 29 Aug. 2019
What do you have to work with? Functions describing the curves? Sampled data that you are plotting? Only the figure itself? Or ...?
Adam Danz
Adam Danz am 29 Aug. 2019
Star Strider
Star Strider am 29 Aug. 2019
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 29 Aug. 2019

0 Stimmen

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

Kategorien

Gefragt:

am 29 Aug. 2019

Kommentiert:

am 29 Aug. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by