V = del2(U)
V = del2(U) returns a matrix V the same size as U with each element equal to the difference between an element of U and the average of its four neighbors. Elements in the interior of the matrix have four neighbors, while elements on the edges and corners have three or two neighbors.
If the matrix U is regarded as a function u(x,y) evaluated at the point on a square grid, then 4*del2(U) is a finite difference approximation of Laplace's differential operator applied to u, that is

where
has
For this function, 4*del2(U) is also 4.
[x,y] = meshgrid(-4:4,-3:3);U = x.*x+y.*yU =25 18 13 10 9 10 13 18 2520 13 8 5 4 5 8 13 2017 10 5 2 1 2 5 10 1716 9 4 1 0 1 4 9 1617 10 5 2 1 2 5 10 1720 13 8 5 4 5 8 13 2025 18 13 10 9 10 13 18 25V = 4*del2(U)V =4 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 4
diff
(c) Copyright 1994 by The MathWorks, Inc.