del2

Purpose

Five-point discrete Laplacian.

Synopsis

V = del2(U)

Description

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

Algorithm

where

Examples

The function

has

For this function, 4*del2(U) is also 4.

[x,y] = meshgrid(-4:4,-3:3);
U = x.*x+y.*y 
          
U =
    25    18    13    10     9    10    13    18    25
    20    13     8     5     4     5     8    13    20
    17    10     5     2     1     2     5    10    17
    16     9     4     1     0     1     4     9    16
    17    10     5     2     1     2     5    10    17
    20    13     8     5     4     5     8    13    20
    25    18    13    10     9    10    13    18    25
          
V = 4*del2(U) 
          
V =
     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     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     4     4     4     4
     4     4     4     4     4     4     4     4     4

See Also

diff

(c) Copyright 1994 by The MathWorks, Inc.