Intersection between the two curves

조회 수: 10 (최근 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 CenterFile Exchange에서 Smoothing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by