% Analytical Solution to Convection-Diffusion Equation
function T = convdiff(u,alpha,L,x,t)
% u = 0.1;
% L = 1;
% alpha = 0.01;
% x = 0.5;
% t = 0;


large = 100;
P = u*L/alpha;

m = [1:large];
betam = (P/2).^2 + (m.*pi()).^2;
lm = alpha.*betam./(L.^2);
Am = (-1).^m.*m./betam.*sin(m.*pi().*x./L).*exp(-lm.*t);
Bm = ((-1).^(m+1).*m./betam.*(1+P./betam).*exp(-P./2)+m.*P./(betam.^2)).*sin(m.*pi().*x./L).*exp(-lm.*t);

SAm = sum(Am);
SBm = sum(Bm);

T = 100.*((exp(P.*x./L)-1)./(exp(P)-1) + (4.*pi().*exp(P.*x./(2.*L)).*sinh(P./2))./(exp(P)-1)*SAm + 2.*pi().*exp(P.*x./(2.*L)).*SBm);