1-Dim wave equation
Finite differences applied to the solution of a 1D wave equation PDE.
Consider the following 1D heat problem where the high function depends on space and time
with initial condition
and boundary conditions
. Solve this problem for the parameter values 
The finite differences equation are (semi-implicit method)
if we define 
then it can written in terms of components as
%-------------------------------------------
%-------------------------------------------
c = 0.05; %propagation coeff.
r = c/dx^2; % dt*c/dx^2; the dt term is added in the solver step
%-----------------------------------------------------
% compute acceleration values (forces) that modify velocity
%-----------------------------------------------------
force(j) = r*(u(jleft)-2*u(j)+u(jright));
%------------------------------------
%Solver: Semi-Implicit Euler Method
%------------------------------------
v = v + dt*force; %update velocities
u = u + dt*v; %update positions with the updated velocities
%------------------------------------
u(1) = 3*sin(5*t); %impose boundary conditions;
% -----------------------------------
text(0,8,['time = ' num2str(t)]);
Exercise 1:
Simulate the results when we consider:
initial condition
and the following initial conditions to create an initial wave:
and 
boundary conditions
.