Main Content


Create solution object

This page describes the legacy workflow. New features might not be compatible with the legacy workflow. For the corresponding step in the recommended workflow, see solvepde and solvepdeeig.

The original (R2015b) version of createPDEResults had only one syntax, and created a PDEResults object. Beginning with R2016a, you generally do not need to use createPDEResults, because the solvepde and solvepdeeig functions return solution objects. Furthermore, createPDEResults returns an object of a newer type than PDEResults. If you open an existing PDEResults object, it is converted to a StationaryResults object.

If you use one of the older solvers such as adaptmesh, then you can use createPDEResults to obtain a solution object. Stationary and time-dependent solution objects have gradients available, whereas PDEResults did not include gradients.



results = createPDEResults(model,u) creates a StationaryResults solution object from model and its solution u.

This syntax is equivalent to results = createPDEResults(model,u,"stationary").


results = createPDEResults(model,u,utimes,"time-dependent") creates a TimeDependentResults solution object from model, its solution u, and the times utimes.


results = createPDEResults(model,eigenvectors,eigenvalues,"eigen") creates an EigenResults solution object from model, its eigenvector solution eigenvectors, and its eigenvalues eigenvalues.


collapse all

Create a StationaryResults object from the solution to an elliptic system.

Create a PDE model for a system of three equations. Import the geometry of a bracket and plot the face labels.

model = createpde(3);
title("Bracket with Face Labels")

title("Bracket with Face Labels, Rear View")

Set boundary conditions: face 3 is immobile, and there is a force in the negative z direction on face 6.


Set coefficients that represent the equations of linear elasticity.

E = 200e9;
nu = 0.3;
c = elasticityC3D(E,nu);
a = 0;
f = [0;0;0];

Create a mesh and solve the problem.

u = assempde(model,c,a,f);

Create a StationaryResults object from the solution.

results = createPDEResults(model,u)
results = 
  StationaryResults with properties:

    NodalSolution: [14314x3 double]
       XGradients: [14314x3 double]
       YGradients: [14314x3 double]
       ZGradients: [14314x3 double]
             Mesh: [1x1 FEMesh]

Plot the solution for the z-component, which is component 3.


Obtain a solution from a parabolic problem.

The problem models heat flow in a solid.

model = createpde();

Set the temperature on face 2 to 100. Leave the other boundary conditions at their default values (insulating).


Set the coefficients to model a parabolic problem with 0 initial temperature.

d = 1;
c = 1;
a = 0;
f = 0;
u0 = 0;

Create a mesh and solve the PDE for times from 0 through 200 in steps of 10.

tlist = 0:10:200;
u = parabolic(u0,tlist,model,c,a,f,d);
173 successful steps
1 failed attempts
337 function evaluations
1 partial derivatives
30 LU decompositions
336 solutions of linear systems

Create a TimeDependentResults object from the solution.

results = createPDEResults(model,u,tlist,"time-dependent");

Plot the solution on the surface of the geometry at time 100.


Create an EigenResults object from the solution to an eigenvalue problem.

Create the geometry and mesh for the L-shaped membrane. Apply Dirichlet boundary conditions to all edges.

model = createpde;
applyBoundaryCondition(model,"dirichlet", ...
                             "Edge",1:model.Geometry.NumEdges, ...

Solve the eigenvalue problem for coefficients c = 1, a = 0, and d = 1. Obtain solutions for eigenvalues from 0 through 100.

c = 1;
a = 0;
d = 1;
r = [0,100];
[eigenvectors,eigenvalues] = pdeeig(model,c,a,d,r);

Create an EigenResults object from the solution.

results = createPDEResults(model,eigenvectors,eigenvalues,"eigen")
results = 
  EigenResults with properties:

    Eigenvectors: [1458x17 double]
     Eigenvalues: [17x1 double]
            Mesh: [1x1 FEMesh]

Plot the solution for mode 10.


Input Arguments

collapse all

PDE model, specified as a PDEModel object.

Example: model = createpde

PDE solution, specified as a vector or matrix.

Example: u = assempde(model,c,a,f);

Times for a PDE solution, specified as a monotone vector. These times should be the same as the tlist times that you specified for the solution by the hyperbolic or parabolic solvers.

Example: utimes = 0:0.2:5;

Eigenvector solution, specified as a matrix. Suppose

  • Np is the number of mesh nodes

  • N is the number of equations

  • ev is the number of eigenvalues specified in eigenvalues

Then eigenvectors has size Np-by-N-by-ev. Each column of eigenvectors corresponds to the eigenvectors of one eigenvalue. In each column, the first Np elements correspond to the eigenvector of equation 1 evaluated at the mesh nodes, the next Np elements correspond to equation 2, and so on.

Eigenvalue solution, specified as a vector.

Output Arguments

collapse all

PDE solution, specified as a StationaryResults object, a TimeDependentResults object, or an EigenResults object. Create results using solvepde, solvepdeeig, or createPDEResults.

Example: results = solvepde(model)



The procedure for evaluating gradients at nodal locations is as follows:

  1. Calculate the gradients at the Gauss points located inside each element.

  2. Extrapolate the gradients at the nodal locations.

  3. Average the value of the gradient from all elements that meet at the nodal point. This step is needed because of the inter-element discontinuity of gradients. The elements that connect at the same nodal point give different extrapolated values of the gradient for the point. createPDEResults performs area-weighted averaging for 2-D meshes and volume-weighted averaging for 3-D meshes.

    Four mesh elements meeting at one node contribute to the averaged value of the gradient at the node

Version History

Introduced in R2015b

expand all