Code covered by the BSD License  

Highlights from
MATLAB Contest Statistics

image thumbnail
from MATLAB Contest Statistics by Matthew Simoneau
The code used to generate the "Statistics" page for the MATLABĀ® Contest.

activityByHour(s,contestName)
function activityByHour(s,contestName)
d = [s.date];
bins = floor(d(1)):(1/24):ceil(d(end));
count = histc(d,bins);
nonempty = find(count ~= 0);
range = min(nonempty):max(nonempty);
%stem(bins(range),count(range),'Marker','none','Color','k')
bar(bins(range)+(bins(2)-bins(1))/2,count(range),'FaceColor','b','EdgeColor','b')
box on
datetick
hold on
set(gca,'GridLineStyle','-')
xlabel('hour of submission')
ylabel('number of entries')
title(['Histogram of All ' num2str(length(s)) ' Contest Entries'])

[periods,periodLabels,prizeTimes,prizeLabels] = getMilestones(contestName);

% Shade background of different time periods.
ylim = get(gca,'ylim');
cmap = brighten(cool(size(periods,1)),.8);
ymax = ylim(2)-5;
for i = 1:size(periods,1)
    area([periods(i,1) periods(i,2) periods(i,2) periods(i,1)],[ylim(1) ylim(1) ylim(2) ylim(2)], ...
        'FaceColor',cmap(i,:),'EdgeColor',lightGray);
    text(mean([periods(i,1) periods(i,2)]),ymax-5,periodLabels{i},'HorizontalAlignment','center');
    kids = get(gca,'Children');
    set(gca,'Children',[kids(3:end); kids(1:2)]);
end

% Label contest deadlines.
for i = 1:length(prizeTimes)
    plot([prizeTimes(i) prizeTimes(i)],get(gca,'Ylim'),'color','k')
    [unused,ind]=min(abs(prizeTimes(i)-bins));
    ypos = count(ind-1)+10;
    %ypos = ymax-10;
    text(prizeTimes(i),ypos,prizeLabels{i},'HorizontalAlignment','center');
end
axis tight

Contact us at files@mathworks.com