clc
clearvars 
close all

degree=input('enter degrees of the polynomial');

for i=1:degree+1
   Coefficient(i)=input(['enter coefficient multiplying x^' num2str(i-1) ': ']);
end
     X=[-100:0.1:100];
     P=0;
for i=0:degree
         P= P+Coefficient(i+1).*X.^i;
end


%this code bellow shows what you need to put to make a graph.
plot(X,P);
s=sign(P);
%the "lims" allow me to put limits on the axis.
ylim([-30,50])
xlim([-6,8])
%The "ticks" show what the number the graph goes up in for example my X
%axis goes up 1 each time.
xticks(-6:1:8)
yticks(-30:5:50)
%the "title" allows me to input a title into my graph, the color allows me
%to change the titles color as an example bellow I've chaged it to blue the
%Fontsize allows me to change the size of the font and the fontweight
%allows me to chage it to bold.
title('Graph of polynomial','Color','b','FontSize',16,'FontWeight','bold');
% The label allows me to add a subheading for each axis.
xlabel('X-axis','Color','r','FontSize',12,'FontWeight','bold');
ylabel('Y-axis','Color','r','FontSize',12,'FontWeight','bold');

y=0.*X;
hold on 
plot(X,y,'-r');
y2=-30:50;
x2=0.*y2;
hold on
plot (x2,y2,'-r');
grid minor

p=1
vs=sign(p)
k2=1
k=1
for i=1:length(vs)-1
    if vs(i)~=vs(i+1),'&'; vs(i)~=0;'&'; vs(i+1)~=0;
        LB(k)=i;
        RB(k)=i+1;
        k=k+1
    end
    if vs(i)==0
        E(k2)=i
        k2=k2+1
    end
end
R1=x(LB)+(x(HB)-x(RB)/2);
R2=x(E);
RT=[R1,R2];