Put your problem in the correct form for Partial Differential Equation Toolbox™ solvers. For details, see Equations You Can Solve Using PDE Toolbox. If you need to convert your problem to divergence form, see Put Equations in Divergence Form.
Create a PDEModel
model container. For scalar PDEs,
use createpde
with no arguments.
model = createpde();
If N is the number of equations in your system, use
createpde
with input argument N
.
model = createpde(N);
Import or create the geometry. For details, see Geometry and Mesh.
importGeometry(model,'geometry.stl'); % importGeometry for 3-D geometryFromEdges(model,g); % geometryFromEdges for 2-D
View the geometry so that you know the labels of the boundaries.
pdegplot(model,'FaceLabels','on') % 'FaceLabels' for 3-D pdegplot(model,'EdgeLabels','on') % 'EdgeLabels' for 2-D
To see labels of a 3-D model, you might need to rotate the model, or make it transparent, or zoom in on it. See STL File Import.
Create the boundary conditions. For details, see Specify Boundary Conditions.
% 'face' for 3-D applyBoundaryCondition(model,'dirichlet','face',[2,3,5],'u',[0,0]); % 'edge' for 2-D applyBoundaryCondition(model,'neumann','edge',[1,4],'g',1,'q',eye(2));
Create the PDE coefficients.
f = [1;2]; a = 0; c = [1;3;5]; specifyCoefficients(model,'m',0,'d',0,'c',c,'a',a,'f',f);
You can specify coefficients as numeric or as functions.
Each coefficient m
, d
,
c
, a
, and f
,
has a specific format. See f Coefficient for specifyCoefficients, c Coefficient for specifyCoefficients, and m, d, or a Coefficient for specifyCoefficients.
For time-dependent equations, or optionally for nonlinear stationary equations, create an initial condition. See Set Initial Conditions.
Create the mesh.
generateMesh(model);
Call the appropriate solver. For all problems except for eigenvalue problems, call
solvepde
.
result = solvepde(model); % for stationary problems result = solvepde(model,tlist); % for time-dependent problems
For eigenvalue problems, use solvepdeeig
:
result = solvepdeeig(model);
Examine the solution. See Solution and Gradient Plots with pdeplot and pdeplot3D, 2-D Solution and Gradient Plots with MATLAB® Functions, and 3-D Solution and Gradient Plots with MATLAB® Functions.
applyBoundaryCondition
| createpde
| generateMesh
| geometryFromEdges
| importGeometry
| pdegplot
| pdeplot
| pdeplot3D