Solving Partial Differential Equations in MATLAB

MATLAB Illustration

MATLAB offers two main approaches for solving partial differential equations (PDEs):

  1. pdepe – Built-in solver for 1-D parabolic and elliptic PDEs in one spatial variable (x) and time (t). Suitable for heat conduction, diffusion, wave equation, and reaction-diffusion systems.
  2. Partial Differential Equation Toolbox – Uses finite element method (FEM) for 2-D and 3-D problems (structural mechanics, heat transfer, electromagnetics, general scalar/vector PDEs).

Using pdepe (1-D PDEs)

PDE must be written in the standard form: c(u,x,t) * ∂u/∂t = ∂/∂x [ f(u,x,t,u_x) ] + s(u,x,t,u,u_x)

Steps:

  1. Define PDE coefficients in a function [c,f,s] = mypde(x,t,u,dudx).
  2. Define initial condition u0(x) = myic(x).
  3. Define boundary conditions [pl,ql,pr,qr] = mybc(xa,ua,xb,ub,t).
  4. Create spatial and time meshes: x = linspace(0,1,50); t = linspace(0,1,100);.
  5. Solve: sol = pdepe(m, @mypde, @myic, @mybc, x, t); (m = 0 for slab/Cartesian, 1 cylindrical, 2 spherical).
  6. Extract solution: u = sol(:,:,k) for k-th equation.
  7. Plot: surf(x,t,u) or pcolor(x,t,u).

Using Partial Differential Equation Toolbox (2-D/3-D)

Steps:

  1. Create model: model = createpde(N); (N = number of equations).
  2. Define geometry (built-in shapes, CSG, or import STL).
  3. Specify PDE coefficients (c, a, f, d terms).
  4. Apply boundary conditions (Dirichlet, Neumann, generalized).
  5. Generate mesh: generateMesh(model);.
  6. Solve:
    • Stationary: result = solvepde(model);
    • Transient: solvepdetransient
    • Eigenvalue: solvepdeeig
  7. Visualize: pdeplot(model,'XYData',u,'Contour','on'); or pdeplot3D.

Ideal for engineering and physics simulations.

What Our Students Say

★★★★★

“I got full marks on my MATLAB assignment! The solution was perfect and delivered well before the deadline. Highly recommended!”

Aditi Sharma, Mumbai
★★★★☆

“Quick delivery and excellent communication. The team really understood the problem and provided a great solution. Will use again.”

John M., Australia

Latest Blogs

Explore how MATLAB Solutions has helped clients achieve their academic and research goals through practical, tailored assistance.

MATLAB R2026a: What's New in the 2026 Release? Major Features & Highlights

MATLAB R2026a (the first major release of 2026) is now available, and it brings a strong mix of AI-powered tools, deeper language integrations, improved productivity features, and performance boosts.