1c4762a1bSJed Brownfunction localF = ex5m(localX,hx,hy,lambda) 2c4762a1bSJed Brown% 3*21afe8ebSBarry Smith% MATLAB routine that does the FormFunction() for ex5.c 4*21afe8ebSBarry Smith% when using the MATLAB engine 5c4762a1bSJed Brown% 6c4762a1bSJed Brown[m,n] = size(localX); 7c4762a1bSJed Brown% 8c4762a1bSJed Brownsc = hx*hy*lambda; hxdhy = hx/hy; hydhx = hy/hx; 9c4762a1bSJed Brown% 10c4762a1bSJed Brown% copy over any potential boundary values 11c4762a1bSJed Brown% 12c4762a1bSJed BrownlocalF = localX; 13c4762a1bSJed Brown% 14c4762a1bSJed Brown% compute interior u and derivatives 15c4762a1bSJed Brown% 16c4762a1bSJed Brownu = localX(2:m-1,2:n-1); 17c4762a1bSJed Brownuxx = (2.0*u - localX(1:m-2,2:n-1) - localX(3:m,2:n-1))*hydhx; 18c4762a1bSJed Brownuyy = (2.0*u - localX(2:m-1,1:n-2) - localX(2:m-1,3:n))*hxdhy; 19c4762a1bSJed Brown% 20c4762a1bSJed Brown% evaluate interior part of function 21c4762a1bSJed Brown% 22c4762a1bSJed BrownlocalF(2:m-1,2:n-1) = uxx + uyy - sc*exp(u); 23c4762a1bSJed Brown% 24c4762a1bSJed Brown% This uses a clever (though not particularly efficient) way of 25c4762a1bSJed Brown% evaluating the function so that it works for any subdomain 26c4762a1bSJed Brown% (with or without any of the true boundary) 27