fem2d_sample, a MATLAB code which evaluates a finite element function of a 2D argument.

The current version of the program can only handle finite element meshes which are made of piecewise linear triangles of order 3 or 6.


fem2d_sample ( 'fem_prefix', 'sample_prefix' )
where 'fem_prefix' is the common prefix for the FEM files: and 'sample_prefix' is the common prefix for the SAMPLE files, for which the node file is input, and the values file is created by the program:


The computer code and data files described and made available on this web page are distributed under the MIT license


fem2d_sample is available in a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:


fem1d_sample, a MATLAB code which samples a scalar or vector finite element function of one variable, defined by FEM files, returning interpolated values at the sample points.

fem2d, a data directory which contains examples of 2D FEM files, text files that describe a 2D finite element geometry and associated nodal values;

fem2d_heat, a MATLAB code which solves the 2D time dependent heat equation on the unit square.

fem2d_pack, a MATLAB code which is useful for 2D finite element calculations.

fem2d_project, a MATLAB code which projects a function F(X,Y) into a given finite element space of piecewise linear triangular elements.

fem3d_sample, a MATLAB code which evaluates a finite element function defined on 3D tetrahedral mesh.

histogram_data_2d_sample, a MATLAB code which demonstrates how to construct a Probability Density Function (PDF) from a frequency table over a 2D domain, and then to use that PDF to create new samples.

histogram_pdf_2d_sample, a MATLAB code which demonstrates how uniform sampling of a 2D region with respect to some known Probability Density Function (PDF) can be approximated by decomposing the region into rectangles, approximating the PDF by a piecewise constant function, constructing a histogram for the CDF, and then sampling.

rejection_sample, a MATLAB code which demonstrates acceptance/rejection sampling.


  1. Hans Rudolf Schwarz,
    Finite Element Methods,
    Academic Press, 1988,
    ISBN: 0126330107,
    LC: TA347.F5.S3313..
  2. Gilbert Strang, George Fix,
    An Analysis of the Finite Element Method,
    Cambridge, 1973,
    ISBN: 096140888X,
    LC: TA335.S77.
  3. Olgierd Zienkiewicz,
    The Finite Element Method,
    Sixth Edition,
    Butterworth-Heinemann, 2005,
    ISBN: 0750663200,
    LC: TA640.2.Z54.

Source Code:

Last revised on 25 October 2022.