


The 5-points Laplacian stencil for arbitrary step sizes in X/Y Input: hx: grid step size in X (defaults to 1 if not set) hy: grid step size in Y (defaults to hx if not set) Output: stencil: the 3x3 5-points Laplacian stencil


0001 function stencil = laplacian5PointsStencil(hx, hy) 0002 % The 5-points Laplacian stencil for arbitrary step sizes in X/Y 0003 % 0004 % Input: 0005 % hx: grid step size in X (defaults to 1 if not set) 0006 % hy: grid step size in Y (defaults to hx if not set) 0007 % 0008 % Output: 0009 % stencil: the 3x3 5-points Laplacian stencil 0010 % 0011 0012 if nargin < 1 0013 hx = 1; 0014 end 0015 if nargin < 2 0016 hy = hx; 0017 end 0018 0019 stencil = hx * [ 0 0 0; 1 -2 1; 0 0 0 ] + hy * [ 0 1 0; 0 -2 0; 0 1 0 ];