del2
Discrete Laplacian of an array.
Category: Mathematics > Numerical Integration and Differential Equations
Syntax
L = del2(U)
Returns the discrete Laplacian of U with unit spacing, scaled by 1/4 for a matrix (1/2n for n dimensions).
L = del2(U, h)
Uses the spacing h in all directions.
L = del2(U, hx, hy, ...)
Uses a separate spacing for each dimension.
Description
In the interior, each value is the mean of the second differences along every dimension, which approximates one fourth of the Laplacian d2u/dx2 + d2u/dy2 for a matrix. Near the edges, the stencil is extrapolated linearly from the neighbors.
Multiply by 4 (for a matrix) to get the plain Laplacian. For a quadratic function, the discrete Laplacian is exact and constant.
Input arguments
U- Numeric vector, matrix or N-D array of samples on a regular grid.
h, hx, hy- Scalar spacings, or coordinate vectors.
Output arguments
L- Array the same size as
U.
Example
Laplacian of x^2 + y^2
[X, Y] = meshgrid(0:4);
U = X.^2 + Y.^2;
4*del2(U)
Output
ans = 5×5
4 4 4 4 4
4 4 4 4 4
4 4 4 4 4
4 4 4 4 4
4 4 4 4 4