clc %......................................................................Clears command window
clear all %................................................................Clears Workspace 
close all %................................................................Closes open graphs/tables

d=input('enter a value for the degree of the polynomial: '); %.............Asks user to input a degree value and allocates to d

for c=1:d+1 %..............................................................Creates a loop for user to enter coeff values
    coef(c)=input(['Enter coeff to multiply x^',num2str(c-1),': ']); %.....Use range c to determine how many values need inputting
end


x=-100:0.1:100; %..........................................................Allocates a range of values with a step size of 0.1 between -100 and 100 to x

y=0;
for i=0:d
    y=y+coef(i+1)*x.^i;
end
y;

plot(x,y,'B') %............................................................Plots a graph of x against y in blue
title('Graph Of Polynomial','color','b','FontSize',12,'FontWeight','bold')%Sets graph title and properties
xlabel('x-axis','color','r','FontSize',12,'FontWeight','bold')%............Sets axis titles and properties
ylabel('y-axis','color','r','FontSize',12,'FontWeight','bold')
grid on %..................................................................Toggles major grid lines
grid minor %...............................................................Toggles minor grid lines

vs=sign(y);

k=1

for        i=1:2000
    if vs(i)~=vs(i+1) & vs(i)~=0 & vs(i+1)~=0
        rootlocation(k)= i
        k = k+1
    end
end


