Graphics Programs Reference
In-Depth Information
surf(x,t,u); title(['Numerical solution',...
'computed with 21 mesh points in x.'])
xlabel('x'), ylabel('t'), zlabel('u')
% A solution profile can also be illuminating.
figure
plot(x,u(end,:))
title('Solution att=4')
xlabel('x'), ylabel('u(x,4)')
%----------------------------------------------------------
function [c,f,s] = pdex(x,t,u,DuDx)
c=1;
f = (1 + (x/5).ˆ2)*DuDx;
% flux is variable conductivity times u x
s=0;
% ---------------------------------------------------------
function u0 = pdexic(x)
% initial condition att=0
u0 = 20+5*sign(x);
% ---------------------------------------------------------
function [pl,ql,pr,qr] = pdexbc(xl,ul,xr,ur,t)
% q's are zero since we have Dirichlet conditions
%pl=0attheleft, pr=0attheright endpoint
pl = ul-15;
ql=0;
pr = ur-25;
qr=0;
Running it gives
heateqex2
Numerical solution computed with 21 mesh points in x.
25
20
15
4
3
5
2
0
1
0
-5
t
x
Search WWH ::




Custom Search