0
0
MATLABdata~20 mins

Scatter plots in MATLAB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Scatter Plot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Basic Scatter Plot Command
What will be the output of the following MATLAB code snippet?
MATLAB
x = 1:5;
y = [2 4 6 8 10];
scatter(x, y, 'filled')
AA scatter plot with 5 blue filled circles at points (1,2), (2,4), (3,6), (4,8), (5,10)
BA scatter plot with 5 red filled circles at points (1,2), (2,4), (3,6), (4,8), (5,10)
CA line plot connecting points (1,2), (2,4), (3,6), (4,8), (5,10)
DSyntax error due to missing marker size argument
Attempts:
2 left
💡 Hint
The 'filled' option fills the markers with the default color.
Predict Output
intermediate
2:00remaining
Effect of Marker Size in Scatter Plot
What is the effect of the marker size argument in this MATLAB scatter plot code?
MATLAB
x = 1:3;
y = [3 6 9];
scatter(x, y, 100, 'r')
ASyntax error because marker size must be a vector
BPlots 3 red circles with default marker size at points (1,3), (2,6), (3,9)
CPlots 3 red circles with marker size 100 (large markers) at points (1,3), (2,6), (3,9)
DPlots 3 blue circles with marker size 100 at points (1,3), (2,6), (3,9)
Attempts:
2 left
💡 Hint
The third argument in scatter is the marker size in points squared.
🔧 Debug
advanced
2:00remaining
Identify the Error in Scatter Plot Code
What error will this MATLAB code produce when run?
MATLAB
x = 1:4;
y = [2 4 6];
scatter(x, y)
AError: Vectors x and y must be the same length
BNo error, plots 3 points ignoring extra x value
CError: Missing marker size argument
DPlots 4 points with y values repeated
Attempts:
2 left
💡 Hint
Check the length of x and y vectors.
🧠 Conceptual
advanced
2:00remaining
Understanding Color Mapping in Scatter Plots
Given the code below, what does the vector 'c' control in the scatter plot?
MATLAB
x = 1:5;
y = [5 4 3 2 1];
c = [10 20 30 40 50];
scatter(x, y, 100, c, 'filled')
colorbar
A'c' is ignored because color is set by 'filled'
B'c' controls the size of each marker
C'c' sets the transparency of each marker
D'c' controls the color of each marker based on its value, mapped to a colormap
Attempts:
2 left
💡 Hint
The fourth argument in scatter can be a vector for color data.
🚀 Application
expert
3:00remaining
Creating a Scatter Plot with Variable Marker Sizes and Colors
Which code snippet correctly creates a scatter plot with x and y coordinates, marker sizes proportional to y values, and colors mapped to x values?
Ax = 1:4; y = [10 20 30 40]; scatter(x, y, x, y, 'filled')
Bx = 1:4; y = [10 20 30 40]; scatter(x, y, y, x, 'filled')
Cx = 1:4; y = [10 20 30 40]; scatter(x, y, y, 'filled', x)
Dx = 1:4; y = [10 20 30 40]; scatter(x, y, 'filled', y, x)
Attempts:
2 left
💡 Hint
The third argument is marker size, the fourth is color data.