0
0
MATLABdata~20 mins

Colormap and colorbar in MATLAB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Colormap and Colorbar Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this colormap and colorbar code?
Consider the following MATLAB code snippet:
imagesc(peaks(10));
colormap(jet);
colorbar;

What will the colorbar represent?
MATLAB
imagesc(peaks(10));
colormap(jet);
colorbar;
AA colorbar showing a gradient from blue to red representing the data values
BA colorbar showing a gradient from green to yellow representing the data values
CA colorbar with discrete colors only, no gradient
DNo colorbar will be displayed
Attempts:
2 left
💡 Hint
Think about what the 'jet' colormap looks like and what colorbar does.
Predict Output
intermediate
2:00remaining
What is the effect of changing colormap to 'hot'?
Given this MATLAB code:
imagesc(magic(5));
colormap(hot);
colorbar;

What color range will the colorbar display?
MATLAB
imagesc(magic(5));
colormap(hot);
colorbar;
AA gradient from purple to pink to white
BA gradient from blue to green to yellow
CA gradient from black through red and yellow to white
DA grayscale gradient from black to white
Attempts:
2 left
💡 Hint
Recall the colors in the 'hot' colormap.
Predict Output
advanced
2:00remaining
What error occurs with this colormap command?
What error will this MATLAB code produce?
imagesc(rand(5));
colormap('unknownmap');
colorbar;
MATLAB
imagesc(rand(5));
colormap('unknownmap');
colorbar;
AError: Undefined function or variable 'unknownmap'.
BNo error, displays default colormap
CWarning: Colormap ignored, colorbar not shown
DError: Invalid syntax in colormap function
Attempts:
2 left
💡 Hint
Check if 'unknownmap' is a valid colormap name.
Predict Output
advanced
2:00remaining
What is the number of colors in this colormap?
Consider this MATLAB code:
imagesc(peaks(20));
colormap(parula(10));
colorbar;

How many distinct colors does the colormap have?
MATLAB
imagesc(peaks(20));
colormap(parula(10));
colorbar;
A20
B256
C64
D10
Attempts:
2 left
💡 Hint
Look at the argument passed to parula.
🧠 Conceptual
expert
3:00remaining
How does colorbar scale relate to data range?
In MATLAB, if you use:
imagesc(data);
colormap(jet);
colorbar;

and then change the color limits with:
caxis([10 20]);

What effect does this have on the colorbar and image colors?
MATLAB
imagesc(data);
colormap(jet);
colorbar;
caxis([10 20]);
AThe colorbar scale remains unchanged; image colors do not change
BThe colorbar scale adjusts to show colors only for data values between 10 and 20; values outside are clipped
CThe colorbar disappears because caxis limits are set manually
DThe image colors invert, showing low values as high colors
Attempts:
2 left
💡 Hint
Think about what caxis does to color scaling.