% Math 3150-4 Computer Lab - Fernando Guevara Vasquez
%
% Animates snapshots of string from Computer Lab 2b
x = linspace(0,1); % equally spaced nodes

figure(1); clf; % create a new figure and reinitialize it
for t=linspace(0,2,20),    
 u = sin(pi*x)*cos(pi*t) - (1/2)*sin(2*pi*x)*cos(2*pi*t) ...
   + (1/3)*sin(3*pi*x)*cos(3 *pi*t);
 plot(x,u);
 axis([0 1 -2 2]); % keep axis fixed so that axis are not tight around function
 pause(0.1);       % specifies amount of time in seconds to pause to display solution
end;

xlabel('x');
ylabel('u(x,t)');
