Personal Website:
Scott Congreve

Teaching

Download<< Back

function dxdt = fdode(t, x, N)
%FDODE Implements the right-hand side of the ODE system derived
% from the heat equation PDE: u_t = u_xx in 0<=x<=pi with zero boundary
% conditions and space discretisation into N+2 nodes.
%
h = pi/(N+1);
d = ones(N,1);
A = spdiags([d -2*d d], [-1 0 1], N, N)/(h^2);
dxdt = A*x;

end