# Plotting graph using roots

32 views (last 30 days)
Mark Davies on 13 Dec 2019
Commented: Mark Davies on 13 Dec 2019
I have calculated the roots of ? = ? 3 + 5.5? 2 + 3.5? − 10 (p=[1 5.5 3.5 -10]; >> x=roots(p) x = -4.0000 -2.5000 1.0000) How do I plot this on a single graph (The curve y for −5 ≤ ? ≤ 3.). Any help will be appreciated:)

ME on 13 Dec 2019
The roots you have calculated are the x values where y = 0. Therefore to plot these on a graph you can use:
p = [1 5.5 3.5 -10];
x = roots(p);
xaxis = -5:0.1:3;
y= xaxis.^3 + 5.5.*xaxis.^2 + 3.5.*xaxis - 10;
plot(xaxis,y,'-',x,zeros(size(x)),'o');
This shows the curve of the function over your specified interval and then plots circles at the roots you have obtained to highlight their location on the plot.
Mark Davies on 13 Dec 2019
Thanks for the info :)

### Categories

Find more on Scatter Plots in Help Center and File Exchange

R2019b

### Community Treasure Hunt

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

Start Hunting!