clc %This is to clear the command window
clear all %This is used to clear the workspace

d=input('Please Enter The Degree Of Your Polynomial: '); %This asks users to input a polynomial of their choice assigning it to the variable "d"
for n=1:d+1 %This is used to create a loop that generates a range of values from 1 to d+1
    coef(n)=input(['Please Enter The Coefficient Of x^',num2str(n-1),': ']); %This asks a user to input a coefficient for x
end

ylim([-30,50]) %This is to set the limit for the "y" axis
xlim([-6,8]) %This is to set the limit for the "x" axis
xticks(-6:1:8) %This gives lines to mark the measurements on the "x" axis
yticks(-30:5:50) %This gives lines to mark the measurements on the "y" axis


x=-100:0.1:100; %This is to generate a range of values for "x" with a given interval of 0.1 from -100 to 100
y=0; %This is used to place "y" into the script ready for the next phase
for i=0:d %This is used to create values for "i" from 0 up to the value of "d" using "i" as a loop counter
    y=y+coef(i+1).*x.^i;%This is used to to calculate values for "y" using the relative values for "x"
    
end
y; %This is used to collect the values for "y"

p=y; %This allocates "y" in the variable "p"

plot(x,p,'color',[0,0,1]) %This is to plot and chose the colour of the polynomial

title('Graph Of Polynomial','color',[0,0,1],'Fontsize',16,'fontweight','bold');  %This is use to display the title of the graph and format of thee title

xlabel('X-Axis','color',[1,0,0],'FontSize',12,'FontWeight','Bold'); %This is used to chose the colour and format of the x-axis name

ylabel('Y-Axis','color',[1,0,0],'FontSize',12,'FontWeight','Bold'); %This is used to chose the colour and format of the y-axis

grid on; %This is used to display the major gridlines

grid minor; %This is used to display the minor gridlines

