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