Graphics Programs Reference
In-Depth Information
solution to heat equation in a rod
25
20
15
20
15
5
10
0
5
0
5
t
x
Note how similar this is to the picture obtained before. We leave it to the
reader to modify the model for the case of variable heat conductivity.
Solution with pdepe
A new feature of MATLAB 6.0 is a built-in solver for partial differential
equations in one space dimension (as well as time t ). To find out more about
it, read the online help on pdepe . The instructions for use of pdepe are quite
explicit but somewhat complicated. The method it uses is somewhat similar
to that used in the SIMULINK solution above; that is, it uses an ODE solver
in t and finite differences in x . The following M-file solves the second
problem above, the one with variable conductivity. Note the use of function
handles and subfunctions.
function heateqex2
% Solves a sample Dirichlet problem for the heat equation in a
% rod, this time with variable conductivity, 21 mesh points
m = 0; %This simply means geometry is linear.
x = linspace(-5,5,21);
t = linspace(0,4,81);
sol = pdepe(m,@pdex,@pdexic,@pdexbc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1);
% A surface plot is often a good way to study a solution.
Search WWH ::




Custom Search