Partial Differential Equation Toolbox |

Solving the Parabolic Equation in Stages

The following example shows you how to solve a parabolic equation in stages and how to set an initial condition as a variable:

1. At the MATLAB command prompt, type `pdetool`.
2. Draw a rectangle in the GUI axes.
3. From the Draw menu, select Export Geometry Description, Set Formula, Labels.
4. In the Export dialog box, enter `gd sf ns`. Click OK.

1. The exported variables are available in the MATLAB workspace.

5. From the Boundary menu, select Boundary mode.
6. From the Boundary menu, select Specify Boundary Conditions.
7. Set the Neuman and Dirichlet boundary conditions. If these conditions are not the same for all the stages, set the conditions accordingly.
8. From the Boundary menu, select Export Decomposed Geometry, Boundary Cond's.
9. In the Export dialog box, enter `g b`. Click OK.
10. From the PDE menu, select PDE Mode.
11. From the PDE menu, select PDE Specification.
12. Set the partial differential equation (PDE) coefficients, which are the same for any value of time.
13. From the PDE menu, select Export PDE Coefficients.
14. In the Export dialog box, enter `c a f d`. Click OK.
15. From the Mesh menu, select Mesh mode.
16. From the Mesh menu, select Parameters.
17. Verify the initial mesh, jiggle mesh, and refine mesh values. Note that the mesh is fixed for all stages.
18. From the Mesh menu, select Export Mesh.
19. In the Export dialog box, enter `p e t`. Click OK.
20. Save the workspace variables into a MAT-file by typing `save data.mat` at the MATLAB command prompt.
21. Save the following code as an M-file:

-     clear all;
      close all;
      load data

      %For the first stage you need to specify an initial condition, U0.
      U0 = 0; %Note that U0 expands to the correct size automatically.

      %Divide the time range into 4 stages.
      time = {0:.01:1, 1:.05:3, 3:.1:5, 5:.5:20};

      for i = 1:4
      U1 = parabolic(U0,time{i},b,p,e,t,c,a,f,d);
      for j = 1:size(U1,2)
      H =pdeplot(p,e,t,'xydata',U1(:,j),'zdata',U1(:,j),'mesh','off');
      set(gca,'ZLim',[-80 0]);
      drawnow
      end
      %Reset the initial condition at all points.
      U0 = U1(:,1);
      end

1. This M-file uses the variables you defined in the MATLAB workspace to solve a parabolic equation in stages. Within this M-file, you set the initial condition as a variable.

| Reducing the Parabolic Equation to Elliptic Equations |  | The Hyperbolic Equation |