help using fzero to find the intersection
Mostrar comentarios más antiguos
i basically want to use fzero in order to find the coordinates of intersection between 2 graphs plotted together on the same figure can someone please explain how this is carried out
Respuestas (2)
KSSV
el 29 de Mayo de 2020
0 votos
2 comentarios
Ziad Badreldeen
el 29 de Mayo de 2020
KSSV
el 29 de Mayo de 2020
so attach your data..to find out whether fzero helps.
Star Strider
el 29 de Mayo de 2020
At the intersections, the difference between the functions is 0, and since fzero is a root-finding algorithm, choose and appropriate starting poiint and use it to find the intersections:
f = @(x) x.^2 - 2;
g = @(x) sin(2*pi*x/10);
for k = 1:2
xint(k) = fzero(@(x)f(x)-g(x), 5*(-1)^k); % Calculate ‘x’ At The Intersections
end
x = linspace(-2, 2);
figure
plot(x, f(x), x, g(x))
hold on
plot(xint, f(xint), 'gp') % Choose Either Function To Plot The Intersections
hold off
grid
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!