Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a contour plot of matrix Z.
MATLAB
contour([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plot instead of contour.
Using mesh or surf which create 3D plots.
✗ Incorrect
The contour function creates contour plots of the matrix Z.
2fill in blank
mediumComplete the code to generate X and Y grid matrices for contour plotting.
MATLAB
[X, Y] = meshgrid([1], [2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing matrix Z instead of vector x.
Using contour or Y as input which are not vectors.
✗ Incorrect
The meshgrid function creates grid matrices from vector x for X and Y.
3fill in blank
hardFix the error in the code to plot contour lines with 10 levels.
MATLAB
contour(X, Y, Z, [1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around 10 making it a string.
Using brackets which create an array.
✗ Incorrect
The number of contour levels should be a numeric scalar, so use 10 without quotes or brackets.
4fill in blank
hardFill both blanks to create a contour plot with labeled contour lines.
MATLAB
C = contour(X, Y, Z, [1]); clabel([2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the data matrix Z instead of the contour matrix C for labeling.
Not specifying the number of contour levels.
✗ Incorrect
Use 20 contour levels and label the contour matrix C returned by contour.
5fill in blank
hardFill all three blanks to create a filled contour plot with a colorbar and title.
MATLAB
contourf(X, Y, Z, [1]); colorbar([2]); title([3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect colorbar location strings.
Not quoting the title string.
✗ Incorrect
Use 15 contour levels, place the colorbar outside on the east, and add a descriptive title.