% Solution Heat Equation with FT
% Arbitrary f(x)

N1 = 201; N2 = 201;
tv = linspace(0.0001,20,N1);
xv = linspace(-10,10,N2);
[t1,x1] = ndgrid(tv,xv);
f = @(s,c) sqrt(pi/c(1))*exp(-(c(2)-s).^2/(4*c(1)));

for i = 1:N1
    for j = 1:N2
        c = [t1(i,j),x1(i,j)];        
        U(i,j) = (1/(2*pi))*integral(@(s)f(s,c),-2,2);
    end
end

set(gca,'FontSize',[12]);
surf(t1,x1,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 heatFTarbf.png	
print -depsc heatFTarbf.eps