# Plot for Total views and likes of Teja's Webcam Sudoku Solver video on YouTube

## This plot is broken.

```Error using dateformverify (line 18)
DATESTR failed converting date number to date vector.  Date number out of range.

Error in datestr (line 195)
S = dateformverify(dtnumber, dateformstr, islocal);```
• Created by: Toshiaki Takeuchi
• Latest result: Error using dateformverify (line 18) DATESTR failed converting date number to date vector. Date number out of range. Error in datestr (line 195) S = dateformverify(dtnumber, dateformstr, islocal);
• Created on: 06 Feb 2012

"Total Views" and "likes" from Solving a Sudoku Puzzle Using a Webcam by Teja on YouTube and track its growth.

このビデオには 日本語バージョン もあります。

```% time1383 and data1383 available for use
% for Total likes of Teja's Webcam Sudoku Solver video on YouTube
%
% Total views of Teja's Webcam Sudoku Solver video on YouTube
%   time vector is: time1382
%   data vector is: data1382

subplot(2,1,1)

% Fit the growth of total views
[p,S,mu] = polyfit(time1382,data1382,1);
p1 = [p(1)/mu(2) p(2)-p(1)*mu(1)/mu(2)];

% Project into the future
tf = [time1382; time1382(end)+1];
df = polyval(p1,tf);

% Predict the number for the next day
d=round(df(end));
t=datestr(time1382(end)+1,1);
s=sprintf('Prediction for %s: %d followers',t,d);

% Predict when it will reach a goal
goal = 8000;
g = sprintf('Will reach %d views on ', goal);
g = [g datestr((goal - p1(2))/p1(1),1)];

% Was previous prediction correct?
[p,S,mu] = polyfit(time1382(1:end-1),data1382(1:end-1),1);
p2 = [p(1)/mu(2) p(2)-p(1)*mu(1)/mu(2)];
prev = polyval(p2,time1382(end-1)+1);
prev = round(prev);
gap = prev-data1382(end);
t=datestr(time1382(end),1);
p=sprintf('Prev Prediction for %s off by %d',t,gap);

% Plot the data and trend
plot(time1382,data1382, '-');
hold on
line(tf,df,'Color','magenta','LineStyle','-')
plot(time1382(end),prev, 'ro');
datetick
title('Total views of Teja''s Sudoku video')
legend('Total Views','Trend','Prev Prediction', 'Location', 'Northwest')
xlabel(s)
hold off

% Get normalized position for annotation
xrange = xlim;
xmin = xrange(1);
xmax = xrange(2);
yrange = ylim;
ymin = yrange(1);
ymax = yrange(2);

XPos = xmin+0.35*(xmax-xmin);
YPos1 = ymin+0.2*(ymax-ymin);
YPos2 = ymin+0.1*(ymax-ymin);
text(XPos,YPos1,p)
text(XPos,YPos2,g)

subplot(2,1,2)