For the following two-variable function: z = 2x sin(x) + xy cos(2y) i. Plot a 3D mesh for z, for the range: -2 lessthanorequalto x lessthanorequalto 2 and -3 lessthanorequalto y lessthanorequalto 3 in steps of 0.1, and add labels for all axes. ii. Find the minimum and maximum values of z. iii. Use contour plots to find two different values for (x, y), when z- = +1. iv. Plot a 2 times 2 mesh graph array showing the cross sections x-y, x-z, y-z, in graphs (1), (2), and (3), respectively, while the 3D x-y-z in graph (4). Add labels and titles. v. Use MATLAB help to display the contour lines for z = 0, 1 and 4 only, while showing the values of the contour levels for x greaterthanorequalto 0, y greaterthanorequalto 0.
Expert Answer
Copyable code:
iv.
MATLAB CODE:
%Create mesh grid
[X,Y]=meshgrid(linspace(0,2*pi));
%Find Z
Z=2*X.*sin(X)+X.*Y.*cos(2*Y);
%graph 1
subplot(2,2,1);
%Plot X-Y
mesh(X,Y); title(‘X vs Y’);
%Graph 2
subplot(2,2,2);
%Plot X-Z
mesh(X,Z); title(‘X vs Z’);
%Graph 3
subplot(2,2,3);
%Plot Y-Z
mesh(Y,Z); title(‘Y vs Z’);
%Graph 4
subplot(2,2,4);
%Plot X vs Y vs Z
mesh(X,Y,Z); title(‘X,Y,Z’);
v.
MATLAB CODE:
%Create mesh grid
[X,Y]=meshgrid(linspace(0,2*pi));
%Find Z
Z=2*X.*sin(X)+X.*Y.*cos(2*Y);
%Contour plot
[CC,hh]=contour(Z,[0, 1, 4]);
%label
clabel(CC,hh)