%define a row 101-dim vector x=[0, 0.01, 0.02, 0.03, ... 0.98, 0.99, 1]
x = 0:0.01:1;
% define a 40*101 zero matrix u(t,x)
u = zeros(40,101);

% make the first row vector of u = sin(2*pi*x)
u(1,:) = sin(2*pi*x);

% Now, the i+1st row of u is equal to 
% the ith row of u shifted to the right
% repeat this process for all rows
for i=2:40
  u(i,2:101) = u(i-1,1:100);
end

% draw the first row of u  (time=0)
figure(1);
plot(u(1,:));
title('u(0,x)');
xlabel('x');
ylabel('u');

% draw the surface u(t,x)
figure(2);
surf(u);
title('u(t,x)');
xlabel('x');
ylabel('t');
zlabel('u');

% draw the last row of u (at the last time step)
figure(3);
plot(u(40,:));
title('u(0,x)');
xlabel('x');
ylabel('u');

% draw u(t,0.5)
figure(4);
plot(u(:,51));
title('u(t,0.5)');
xlabel('t');
ylabel('u');