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