0
0
MATLABdata~20 mins

Axis control and formatting in MATLAB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Axis Mastery
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 axis limit setting?
Consider the following MATLAB code snippet that plots a sine wave and sets axis limits. What will be the x-axis limits after running this code?
MATLAB
x = linspace(0, 2*pi, 100);
y = sin(x);
plot(x, y);
axis([0 pi -1 1]);
xl = xlim;
A[0 2]
B[0 6.2832]
C[-1 1]
D[0 3.1416]
Attempts:
2 left
💡 Hint
The axis function sets limits as [xmin xmax ymin ymax].
Predict Output
intermediate
2:00remaining
What is the y-axis tick labels after formatting?
Given the code below, what will be the y-axis tick labels displayed on the plot?
MATLAB
y = [10 20 30 40 50];
plot(y);
yticks([10 30 50]);
yticklabels({'Low', 'Medium', 'High'});
ALow, Medium, High
B10, 30, 50
C1, 2, 3
D10, 20, 30, 40, 50
Attempts:
2 left
💡 Hint
yticklabels replaces numeric tick labels with strings.
🔧 Debug
advanced
2:00remaining
Why does this axis command cause an error?
The following MATLAB code attempts to set axis limits but causes an error. Identify the cause.
MATLAB
x = 1:10;
y = x.^2;
plot(x, y);
axis([0 10]);
Ax and y vectors have different lengths
Baxis requires four values [xmin xmax ymin ymax], but only two are given
Cplot function syntax is incorrect
Daxis limits must be positive numbers only
Attempts:
2 left
💡 Hint
Check the number of elements inside the axis brackets.
🧠 Conceptual
advanced
2:00remaining
Which command freezes the axis limits to prevent automatic changes?
In MATLAB, after plotting data, which command prevents the axis limits from changing when new plots are added?
Aaxis equal
Baxis tight
Caxis manual
Daxis auto
Attempts:
2 left
💡 Hint
Think about how to stop MATLAB from adjusting axis limits automatically.
Predict Output
expert
2:00remaining
What is the number of x-axis ticks after this code runs?
Given the code below, how many tick marks will appear on the x-axis?
MATLAB
x = linspace(0, 10, 100);
y = sin(x);
plot(x, y);
xticks(0:2:10);
A6
B5
C11
D10
Attempts:
2 left
💡 Hint
Count the numbers from 0 to 10 stepping by 2.