% Solutions to the heat flow equation 
% on one-dimensional rod 
% Fourier Transform solution
format compact;
tfin = 100;			% final time
xwid = 10;
k = 1;			    % heat capacitance
NptsT=151;          % number of t pts
NptsX=151;          % number of x pts
t=linspace(0,tfin,NptsT);
x=linspace(-xwid,xwid,NptsX);
[T,X]=meshgrid(t,x);

figure(1)
clf
U = 50*(1 + erf(X./(sqrt(4*k*T))));  % Temperature(n)
    
set(gca,'FontSize',[12]);
surf(T,X,U);
shading interp
colormap(jet)
xlabel('$t$','Fontsize',12,'interpreter','latex'); 
ylabel('$x$','Fontsize',12,'interpreter','latex'); 
zlabel('$u(x,t)$','Fontsize',12,'interpreter','latex');
axis tight
view([30 12])
print -dpng heatFT1.png	
print -depsc heatFT1.eps

figure(2)
clf

set(gca,'FontSize',[12]);
surf(T,X,U);
shading interp
colormap(jet)
view([0 90])             %create 2D color map of temperature
xlabel('$t$','Fontsize',12,'interpreter','latex'); 
ylabel('$x$','Fontsize',12,'interpreter','latex'); 
zlabel('$u(x,t)$','Fontsize',12,'interpreter','latex');
axis tight
colorbar
set(gca,'FontSize',[12]);
print -dpng heatFT2.png
print -depsc heatFT2.eps



