15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Partial Differential Equations<br />

ql = 0;<br />

pr = pi * exp(-t);<br />

qr = 1;<br />

In the function pdex1bc, pl and ql correspond to the left boundary<br />

conditions ( x = 0 ), and pr and qr correspond to the right boundary<br />

condition ( x = 1 ).<br />

5 Select mesh points for the solution. Before you use the <strong>MATLAB</strong> PDE<br />

solver, you need to specify the mesh points ( t,<br />

x)<br />

at which you want pdepe<br />

to evaluate the solution. Specify the points as vectors t and x.<br />

The vectors t and x play different roles in the solver (see “<strong>MATLAB</strong> Partial<br />

Differential Equation Solver” on page 5-91). In particular, the cost and the<br />

accuracy <strong>of</strong> the solution depend strongly on the length <strong>of</strong> the vector x.<br />

However, the computation is much less sensitive to the values in the vector<br />

t.<br />

This example requests the solution on the mesh produced by 20 equally<br />

spaced points from the spatial interval [0,1] and five values <strong>of</strong> t from the<br />

time interval [0,2].<br />

x = linspace(0,1,20);<br />

t = linspace(0,2,5);<br />

6 Apply the PDE solver. The example calls pdepe with m = 0, the functions<br />

pdex1pde, pdex1ic, and pdex1bc, and the mesh defined by x and t at which<br />

pdepe is to evaluate the solution. The pdepe function returns the numerical<br />

solution in a three-dimensional array sol, where sol(i,j,k) approximates<br />

the kth component <strong>of</strong> the solution, u k , evaluated at t(i) and x(j).<br />

m = 0;<br />

sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);<br />

This example uses @ to pass pdex1pde, pdex1ic, and pdex1bc as function<br />

handles to pdepe.<br />

5-97

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!