Enter Coefficients in the PDE App

This example shows how to enter coefficients in the PDE app.

Caution: Do not include spaces in your coefficient strings in the PDE app. The string parser can misinterpret a space as a vector separator, as when a MATLAB® vector uses a space to separate elements of a vector.

The PDE is parabolic,


with the following coefficients:

  • d = 5

  • a = 0

  • f is a linear ramp up to 10, holds at 10, then ramps back down to 0:


  • c = 1 +.x2 + y2

Write the following file framp.m and save it on your MATLAB path.

function f = framp(t)

if t <= 0.1
    f = 10*t;
elseif t <= 0.9
    f = 1;
    f = 10-10*t;
f = 10*f;

Open the PDE app, either by typing pdetool at the command line, or selecting PDE from the Apps menu.

Select PDE > PDE Specification.

Select Parabolic equation. Fill in the coefficients as pictured:

  • c = 1 + x.^2 + y.^2

  • a = 0

  • f = framp(t)

  • d = 5

The PDE app interprets all inputs as strings. Therefore, do not include quotes for the c or f coefficients.

Select Options > Grid and Options > Snap.

Select Draw > Draw Mode, then draw a rectangle centered at (0,0) extending to 1 in the x-direction and 0.4 in the y-direction.

Draw a circle centered at (0.5,0) with radius 0.2

Change the set formula to R1-C1.

Select Boundary > Boundary Mode

Click a segment of the outer rectangle, then Shift-click the other three segments so that all four segments of the rectangle are selected.

Double-click one of the selected segments.

Fill in the resulting dialog box as pictured, with Dirichlet boundary conditions h = 1 and r = t*(x-y). Click OK.

Select the four segments of the inner circle using Shift-click, and double-click one of the segments.

Select Neumann boundary conditions, and set g = x.^2+y.^2 and q = 1. Click OK.

Click to initialize the mesh.

Click to refine the mesh. Click again to get an even finer mesh.

Select Mesh > Jiggle Mesh to improve the quality of the mesh.

Set the time interval and initial condition by selecting Solve > Parameters and setting Time = linspace(0,1,50) and u(t0) = 0. Click OK.

Solve and plot the equation by clicking the button.

Match the following figure using Plot > Parameters.

Click the Plot button.

Related Examples

Was this topic helpful?