clc
clear all %Clean matlab command window and workspace

n=input('Input Degree of Polynomial: '); %User inputted degree of polynomial

for i = 0:n
    c(i+1) = input(['Input coefficient of x^', num2str(i), ': ']); %User input for the rest of the coefficients for the polynomial
end

P = flip(c); %Making the polynomial equation descend in powers
c = -100:100; %Range of x values on graph
v = 0;
var = 0; %Variable for power of x

for i = 0:n
    var = n-i;
    y = P(i+1)*c.^var; %Calculating the y values for all the x values
    v = y+v;
end

plot(c,v) %Plotting the x values against the y values
grid on %Turning the major grid lines on for the background of the graph
grid minor %Turning minor grid lines on
title('Graph of Polynomial','FontSize',16,'FontWeight','Bold','Color','blue') %Formatting the graph title
xlabel('x-axis','FontSize',12,'FontWeight','Bold','Color','red') %Formatting the x axis label
ylabel('y-axis','FontSize',12,'FontWeight','Bold','Color','red') %Formatting the y axis label
xline(0,'Color','red'); %Plotting the line x=0 in red
yline(0,'Color','red'); %Plotting the line y=0 in red

