Method 1: solve equation for y=0
Use the Symbolic Math Toolbox to solve for y=0; see inline comments for details.
syms x
eqn = x.^3/3-4*x == 0;
xInt = double(solve(eqn));
yInt = zeros(size(xInt));
x=linspace(-4,4);
V=(x.^3/3)-4*x;
plot(x,V,'k-')
hold on
plot(xInt,yInt, 'm*','MarkerSize', 10)
yline(0)
Method 2: use intersections() to find x-intercepts
This uses the intersections() function from the file exchange to find the (x,y) coordinates of the x-intercepts. x=linspace(-4,4);
V=(x.^3/3)-4*x;
[xInt,yInt] = intersections(x,V,x,zeros(size(V)));
plot(x,V,'k-')
hold on
plot(xInt,yInt, 'm*','MarkerSize', 10)
yline(0)
Both methods produce this figure
Best Answer