The head of a groundwater aquifer is described in Cartesian coordinates by
Develop a single script to (a) generate contour and mesh subplots of the function in a similar fashion to Example 7.4, and (b) determine the maximum with fminsearch.
Example 7.4:
Visualizing a Two-Dimensional Function
Problem Statement. Use MATLAB’s graphical capabilities to display the following function and visually estimate its minimum in the range –2 ≤ x1 ≤ 0 and 0 ≤ x2 ≤ 3:
Solution. The following script generates contour and mesh plots of the function:
x = linspace(−2,0,40);y = linspace(0,3,40);[X, Y] = meshgrid(x,y);Z = 2 + X − Y + 2 * X.^2 + 2 * X.* Y + Y.^2;subplot(1,2,1);cs = contour(X,Y,Z);clabel(cs);xlabel('x_1');ylabel('x_2');title('(a) Contour plot');grid;subplot(1,2,2);cs = surfc(X,Y,Z);zmin = floor(min(Z));zmax = ceil(max(Z));xlabel('x_1');ylabel('x_2');zlabel('f(x_1,x_2)');title ('(b) Mesh plot');
As displayed in Fig. 7.9, both plots indicate that function has a minimum value of about f(x1, x2) = 0 to 1 located at about x1 = −1 and x2 = 1.5.
FIGURE 7.9 (a) Contour and (b) mesh plots of a two-dimensional function.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.