% 1️⃣ Press ▶️ above.
% 2️⃣ Scroll 👉 to see plot.
% 3️⃣ On 📱, rotate to see code & plot together.
x=linspace(-4,2.5,50)
y=yvalue(x)
plot(x,y,'-o');
hold('on')
[xr,yr]=root()
plot(xr,yr,'xr')
title('Roots of polynomial')
hold('off')
% Evaluate polynomial
function y=yvalue(x)
y=x.^3+3*x.^2-4*x-12;
end
% Roots
function [xr,yr]=root()
xr=roots([1 3 -4 -12]);
yr=yvalue(xr);
end
