%
% plot the transient
% sin(r)/r series solution
% of spherical heat conduction problem
%
% jbr, 11/13/2009
%
nterms = 100;
nrs = 100;
r = linspace(0, 1, nrs)';
tvec = [0.0001, 0.001, 0.01, 0.1, 0.5];
Temp = zeros(nrs, numel(tvec));
sign = 1;
for n = 1: nterms
term = sign*sin(n*pi*r)./(n*pi*r)*exp(-(n*pi)^2*tvec);
% take limit at r=0
if (r(1) == 0 )
term(1,:) = sign*exp(-(n*pi)^2*tvec);
end
Temp = Temp + term;
sign = -sign;
end
Temp = 1 - 2*Temp;
figure()
plot(r,Temp)
output = [r, Temp];
save transsph.dat output;