%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                           %%
%%   Plot the solution of problem 7.28, acoustics in a pipe with the left    %%
%%   end closed and the right end open.                                      %%
%%                                                                           %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% compact printing
format compact

% speed of sound
a=0.5

% length of the pipe
l=.5*pi

% time interval between plots
dtplot=0.25*l/a;

% final time to plot
tplot_max=1.25*l/a;

% number of plot points
imax=100;

% plot points
x=[0:imax]*l/imax;

% number of terms to sum
nmax=100;

% set the values of the Fourier coefficients
for n=1:nmax
  % Fourier coefficient for an .5*pi-x initial condition on u
  fn(n)=1/(2*n-1)^2;
  % Fourier coefficient for a zero initial condition on u_t
  gn(n)=0;
end

% new plot
hold off

% plot the requested times
for t=0:dtplot:tplot_max

    u=p7_28u(x,t,a,l,fn,gn,nmax);
    umax=max(u)
    umin=min(u)

    plot(x,u)
    hold on

end
    
