Main Content


Solve problems that model electric and magnetic fields

In this workflow, you can only specify and store parameters belonging to electromagnetic analysis. To store all physical parameters for structural, thermal, and electromagnetic analyses, and for ease of switching between analyses types, use Unified Modeling. For help migrating your existing code to the unified finite element workflow, see Migration from Domain-Specific to Unified Workflow.

Solve PDEs that model static and time-harmonic electric and magnetic fields. A typical programmatic workflow for solving an electromagnetic problem includes these steps:

  • Create a special electromagnetic model container for an electrostatic, magnetostatic, or harmonic analysis.

  • Define a geometry and mesh it.

  • Assign electromagnetic properties of the material, such as relative permittivity, relative permeability, and conductivity.

  • Specify charge density, current density, and magnetization within the geometry.

  • Specify voltage, magnetic potential, surface current density, and an electric or magnetic field on the boundaries.

  • Specify absorbing boundary conditions.

  • Solve and plot results, such as the resulting electric or magnetic potentials, fields, and flux densities.

Magnetic potential plot in color with the equipotential lines as contours and the magnetic field as arrows


expand all

createpdeCreate model
electromagneticPropertiesAssign properties of material for electromagnetic model (Since R2021a)
electromagneticSourceSpecify current density, charge density, and magnetization for electromagnetic model (Since R2021a)
electromagneticBCApply boundary conditions to electromagnetic model (Since R2021a)
solveSolve structural analysis, heat transfer, or electromagnetic analysis problem
generateMaxwellStressTensorCompute Maxwell stress tensor at nodal locations (Since R2024a)
assembleFEMatricesAssemble finite element matrices
interpolateElectricPotentialInterpolate electric potential in electrostatic or DC conduction result at arbitrary spatial locations (Since R2021a)
interpolateElectricFieldInterpolate electric field in electrostatic or DC conduction result at arbitrary spatial locations (Since R2021a)
interpolateElectricFluxInterpolate electric flux density in electrostatic result at arbitrary spatial locations (Since R2021a)
interpolateMagneticPotentialInterpolate magnetic potential in magnetostatic result at arbitrary spatial locations (Since R2021a)
interpolateMagneticFieldInterpolate magnetic field in magnetostatic result at arbitrary spatial locations (Since R2021a)
interpolateMagneticFluxInterpolate magnetic flux density in magnetostatic result at arbitrary spatial locations (Since R2021a)
interpolateHarmonicFieldInterpolate electric or magnetic field in harmonic result at arbitrary spatial locations (Since R2022a)
interpolateCurrentDensityInterpolate current density in DC conduction result at arbitrary spatial locations (Since R2022b)
interpolateMaxwellStressTensorInterpolate Maxwell stress tensor at arbitrary spatial locations (Since R2024a)
pdeplotPlot solution or mesh for 2-D problem
pdeplot3DPlot solution or surface mesh for 3-D problem
pdegplotPlot PDE geometry
pdemeshPlot PDE mesh
pdevizCreate and plot PDE visualization object (Since R2021a)
findElectromagneticPropertiesFind electromagnetic material properties assigned to geometric region (Since R2021a)
findElectromagneticSourceFind electromagnetic source assigned to geometric region (Since R2021a)
findElectromagneticBCFind electromagnetic boundary conditions assigned to geometric region (Since R2021a)

Live Editor Tasks

Visualize PDE ResultsCreate and explore visualizations of PDE results in the Live Editor (Since R2022b)


ElectromagneticModelElectromagnetic model object (Since R2021a)
ElectrostaticResultsElectrostatic solution and derived quantities (Since R2021a)
MagnetostaticResultsMagnetostatic solution and derived quantities (Since R2021a)
HarmonicResultsHarmonic electromagnetic solution (Since R2022a)
ConductionResultsDC conduction solution (Since R2022b)


ElectromagneticMaterialAssignment PropertiesElectromagnetic material properties assignments (Since R2021a)
ElectromagneticSourceAssignment PropertiesElectromagnetic source assignments (Since R2021a)
ElectromagneticBCAssignment PropertiesElectromagnetic boundary condition assignments (Since R2021a)
PDESolverOptions PropertiesAlgorithm options for solvers
PDEVisualization PropertiesPDE visualization of mesh and nodal results (Since R2021a)


Electrostatic and Magnetostatic Problems

Electromagnetic Equations