필터 지우기
필터 지우기

Finding intersection point between two functions

조회 수: 2 (최근 30일)
Jose Grimaldo
Jose Grimaldo 2020년 4월 14일
답변: Star Strider 2020년 4월 14일
How do can I find the intersection point between anonymous function L and L2 and plot the intersection point?
A=[0 2.5 3.8 4.5 6.7 7.2]
B=[0 0.6 1.1 1.6 2.6 3.7]
P=polyfit(A(1:3),B(1:3));
L=@(x) P(1).*x + P(2);
P2=polyfit(A(4:6),B(4:6));
L2=@(x) P2(1).*x + P2(2);
% Plotting function L from A(1) to intersection point
fplot(L,[A(1),fzero(L2-L,0)]);

답변 (1개)

Star Strider
Star Strider 2020년 4월 14일
Try this:
A=[0 2.5 3.8 4.5 6.7 7.2];
B=[0 0.6 1.1 1.6 2.6 3.7];
P=polyfit(A(1:3),B(1:3),1);
L=@(x) P(1).*x + P(2);
P2=polyfit(A(4:6),B(4:6),1);
L2=@(x) P2(1).*x + P2(2);
R1 = polyval(P,A(1:3));
R2 = polyval(P2,A(4:6));
x_int = (P2(2)-P(2))/(P(1)-P2(1)) % Algebra
y_int = polyval(P, x_int) % ‘polyval’
x_int = fzero(@(x) L(x)-L2(x), 1) % ‘fzero’
y_int = polyval(P, x_int) % ‘polyval’
figure
plot(A, B, '.-')
hold on
plot(A(1:3), R1)
plot(A(4:6), R2)
plot(x_int, y_int, 'p')
hold off
.

카테고리

Help CenterFile Exchange에서 Filter Design에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by