Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a colormap with 64 colors.
MATLAB
cmap = [1](64);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plotting functions instead of colormap functions.
Confusing figure or axis commands with colormap.
✗ Incorrect
The jet function creates a colormap with a specified number of colors.
2fill in blank
mediumComplete the code to add a colorbar to the current figure.
MATLAB
[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
colormap instead of colorbar.Trying to set axis properties instead of adding colorbar.
✗ Incorrect
The colorbar function adds a color scale bar to the figure.
3fill in blank
hardFix the error in the code to apply the 'hot' colormap and show the colorbar.
MATLAB
imagesc(peaks(20)) [1]('hot') colorbar;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
colorbar instead of colormap.Trying to use
axis or caxis incorrectly.✗ Incorrect
The colormap function sets the colormap for the current figure.
4fill in blank
hardFill both blanks to create a figure with a 'parula' colormap and add a colorbar.
MATLAB
imagesc(magic(10)) [1]([2]) colorbar;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
colorbar as the colormap function.Confusing colormap names.
✗ Incorrect
Use colormap to set the colormap and parula as the colormap name.
5fill in blank
hardFill all three blanks to create a heatmap with a 'cool' colormap, set color limits, and add a colorbar.
MATLAB
data = rand(5); imagesc(data) [1]([2]) caxis([3]) colorbar;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
colorbar instead of colormap.Incorrect color limits format.
✗ Incorrect
Set the colormap to 'cool' using colormap, then set color limits with caxis to [0 1].