Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a grid of points using meshgrid.
MATLAB
x = -2:0.5:2; y = -2:0.5:2; [X, Y] = [1](x, y);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using linspace instead of meshgrid.
Trying to use plot to create coordinate matrices.
✗ Incorrect
The meshgrid function creates matrices for X and Y coordinates from vectors x and y, which is needed for 3D surface plotting.
2fill in blank
mediumComplete the code to calculate Z as the sum of squares of X and Y.
MATLAB
Z = [1].^2 + Y.^2;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase x instead of matrix X.
Forgetting the dot before the power operator.
✗ Incorrect
We use X squared plus Y squared to get the surface height Z.
3fill in blank
hardFix the error in the code to plot the surface using surf.
MATLAB
surf(X, Y, [1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing x or y instead of Z to surf.
Trying to use plot instead of surf.
✗ Incorrect
The surf function needs the Z matrix for heights, so we pass Z.
4fill in blank
hardFill both blanks to create a mesh plot and label the axes.
MATLAB
mesh(X, Y, Z); xlabel('[1]'); ylabel('[2]');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Labeling axes incorrectly or swapping labels.
Using 'Z-axis' label for x or y axis.
✗ Incorrect
We label the x-axis as 'X-axis' and the y-axis as 'Y-axis' to describe the plot clearly.
5fill in blank
hardFill all three blanks to create a surface plot with title and color bar.
MATLAB
surf(X, Y, Z); title('[1]'); colorbar; shading [2]; view([3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'flat' shading which is less smooth.
Not setting a proper view angle for 3D visualization.
✗ Incorrect
The title describes the plot, 'interp' smooths colors, and view sets the angle to [45 30].