% Generates demand estiates for n days. Finds the average demand within
% each hourly slot from the n estimates.
function averageDemand = historicProfile(n)
temp = [];
for j=1:n 
    rprofile = getProfile();            % generate a new demand profile
    shortprofile = rprofile.flow(2:end);  % removing the starting point
    bar = [];                               % generate temporary matrix
    for i=1:1:24       % turn minute by minute data into horly averages
        tempy = sum(shortprofile( (i-1)*60+1 : 60+(i-1)*60)/60);
        % finds the average response from: (sum of minute responses)/60
        bar=[bar,tempy];                    % saves the hourly response
    end
    temp = [temp; bar];     % append new hourly data set to temp matrix
end


ad = sum(temp)/n             %add up hourly datasets and divide by days
averageDemand= [ad(5:end),ad(1:4)]    %time shifted to start at 4.00 AM

