clc %Clears the command window
clear all %Clears variable created in Workspace

NOR=xlsread('Assignment_Data.xlsx','B1:P1'); %Reads the excel data from row B1 to P1
NOD=xlsread('Assignment_Data.xlsx','B2:P2'); %Reads the excel data from row B2 to P2
[rN,cN]=size(NOR); %Sets the size of Number of requests
LB=NOR(1); %Sets the lower bracket
span=3; %Sets the span to 3 
HB=LB+span; %Higher bracket is equal to lower bracket plus span
daycount=0; %Sets the daycount to start from 0
k=1; %Sets k to 1
GNOD=15; %Sets GNOD to 15

for i=1:cN %Start of the for loop
    if NOR(i)<HB %If statment 
        daycount=NOD(i)+daycount;
    else %Else statment
        GNOD(k)=daycount;
        daycount=NOD(i);
        k=k+1;
        HB=HB+span;
    end %End of if-else statement
end % End of for loop

GNOD(k)=daycount;
GNOD;
MCV=(LB+span/2:3:HB); %Sets the middle class value
histogram('BinEdges',LB:span:HB,'Bincounts',GNOD,'FaceColor',[ 0 0 1]); %Plots a histogram and manually specifies bin edges and associated bin counts and changes the colous of the histogram bars
hold on %Retains the current plot and certain axes properties so that subsequent graphing commands add to the existing graph
plot(MCV,GNOD,'Color',[1 0 0 ],'LineWidth',1.5); %Plots MCV and GNOD and changes the colour and line width
xticks(15:1.5:33); %Sets the x values in increments of 1.5
yticks(0:1:25); %Sets the y values in increments of 1
xlabel('Number of Request classes'); %Labels the x axis
ylabel('Number of Days'); %Lables the y axis 
title('Histogram and Polygon distribution of data set'); %Titles the histogram
text(25.5,2,'Modal Value=25.5','FontSize',13,'FontWeight','Bold','HorizontalAlignment','Center','Color',[1 1 0 ]); %Adds the the modal value to the histogram and changes the font size and weight, centers it and changes the colour  

F=GNOD/sum(GNOD); %Sets the Frequency
CF=cumsum(F); %Sets the Cumulated Frequency
CFstart=[0 CF]; %Start the CF plot from 0
ICF=cumsum(F,'reverse'); %Sets the Inversely Cumulated Frequency
ICFend=[ICF 0]; %Ends the ICF plot at 0
figure %Creates a new figure window
plot([LB:span:HB],ICFend,'LineWidth',1.5,'LineStyle','-.','Color',[1 0 0 ],'Marker','o'); %Plots the ICF curve and changes the line width, style, colour and marker
hold on %Retains the current plot and certain axes properties so that subsequent graphing commands add to the existing graph
plot([LB:span:HB],CFstart,'LineWidth',1.5,'LineStyle','--','Color',[ 0 0 1],'Marker','o'); %Plots the CF curve and changes the line width, style, colour and marker
xlabel('xi'); %Labels the x axis
ylabel('Frequencies'); %Labels the y axis
grid on %Adds a grid to the Ogive plot
title('Ogive Distirbution Frequencies'); %Titles the Ogive plot