Intersection point of x axis

57 views (last 30 days)
Rajendran Senthilkumar
Rajendran Senthilkumar on 22 Nov 2020
Commented: Star Strider on 5 Dec 2022
How do i plot intersection point of a curve with x axis?

Answers (1)

Star Strider
Star Strider on 22 Nov 2020
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
Steven
Steven on 4 Dec 2022
This worked perfectly for my equation thank you

Sign in to comment.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!