File Exchange

image thumbnail

Fast assembly of stiffness and matrices in finite element method using nodal elements

version 1.15 (845 KB) by

vectorization of FEM matrices assembly



View License

This code demonstrates vectorization concepts from the paper:
Talal Rahman and Jan Valdman: Fast MATLAB assembly of FEM matrices in 2D and 3D: nodal elements, Applied Mathematics and Computation 219, 7151–7158 (2013).
A link to the paper can be found at the author web page located at
Please cite the paper if you find the code useful.
Description; To run the code, call
"start_assembly_P1_3D" or "start_assembly_P1_2D"
in the Matlab window to perform tests for nodal P1 (linear) elements defined on 2D triangular or 3D tetrahedral mesh. For a given mesh, mass and stiffness matrices are generated in a fast vectorized way.

Functionality is extended to generate mass and stiffness matrices for a (vector) linear elasticity problem.

To run the code, call

"start_assembly_P1_3D_elasticity" or "start_assembly_P1_2D_elasticity".

Tien Dat Ngo (EFPL Lausanne) added assembly of stiffness matrices in linear elasticity for linear elements on a hexahedral mesh

To run the code, call


If you are new to a Matlab vectorization, you can call


to see that the vectorized code beats the serial version in the computation of triangular areas.

Comments and Ratings (2)



P1 coefficients for mass matrices (both 2D and 3D) added


P0 coefficients added to assemblies of mass matrices in both 2D and 3D


new functionality added: elementwise constant coefficients


paper info completed


improved description


Q1 assembly in 3D for linear elasticity added thanks to Tien Dat Ngo.


Paper information added


report link add, extended to work for linear elasticity


tested for both linux and windows


added start_calculate_areas


2D functionality added

MATLAB Release
MATLAB 8.4 (R2014b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video