Intersection point of x axis

Answers (1)

It depends on the curve and how you define it.
Example —
x = linspace(-5, 5);
y = x.^2-2;
zx = find(diff(sign(y)));
for k = 1:numel(zx)
xint(k) = interp1(y(zx(k)+[-1 1]), x(zx(k)+[-1 1]), 0);
end
figure
plot(x, y)
hold on
plot(xint, zeros(size(xint)), 'p')
hold off
grid
.

2 Comments

This worked perfectly for my equation thank you
My pleasure!

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Release

R2020b

Commented:

on 5 Dec 2022

Community Treasure Hunt

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

Start Hunting!