function simpleFTCS_heat_animated() close all dt = 0.0005; N = 25; fT = 0.2; x = linspace(0,1,N)'; dx = x(2) - x(1); v = zeros(N,1); % solution at time level n+1 vOld = zeros(N,1); % solution at time level n vOld = sin(pi*x); % initial condition v = vOld; r = dt/dx^2 t = 0; % plot(x,vOld,'b') ve = sin(pi.*x); hh = plot(x,v,x,ve,'erasemode','xor'); set(hh(1),'Color',[0 0 1]); % numerical in blue set(hh(2),'Color',[1 0 0]); % exact in red set(hh(2),'LineStyle','--'); axis([0 1 -0.05 1.05]); pause % hit any key to continue while t