0
0
MATLABdata~10 mins

plot() function basics in MATLAB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to plot the vector y against x.

MATLAB
x = 1:5;
y = [2, 4, 6, 8, 10];
plot([1], y);
Drag options to blanks, or click blank then click option'
Ax
By
Cplot
D1:5
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping x and y in the plot function.
Using the function name 'plot' as an argument.
2fill in blank
medium

Complete the code to add a title to the plot.

MATLAB
x = 1:5;
y = [2, 4, 6, 8, 10];
plot(x, y);
title([1]);
Drag options to blanks, or click blank then click option'
Ax
By
C'My Plot'
Dplot
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable instead of a string to title.
Not using quotes around the title text.
3fill in blank
hard

Fix the error in the code to plot y versus x with red circles.

MATLAB
x = 1:5;
y = [2, 4, 6, 8, 10];
plot(x, y, [1]);
Drag options to blanks, or click blank then click option'
A'ro'
B'-b'
C'g*'
D'--k'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a line style without marker symbols.
Using a color code without marker symbols.
4fill in blank
hard

Fill both blanks to create a plot of y versus x with blue dashed lines and add an x label.

MATLAB
x = 1:5;
y = [2, 4, 6, 8, 10];
plot(x, y, [1]);
xlabel([2]);
Drag options to blanks, or click blank then click option'
A'--b'
B'-r'
C'X Axis'
D'Y Axis'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong color or line style.
Not using quotes around the label text.
5fill in blank
hard

Fill all three blanks to plot y versus x with green stars, add a title, and label the y-axis.

MATLAB
x = 1:5;
y = [2, 4, 6, 8, 10];
plot(x, y, [1]);
title([2]);
ylabel([3]);
Drag options to blanks, or click blank then click option'
A'g*'
B'My Green Plot'
C'Y Axis'
D'X Axis'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up x and y labels.
Not using quotes for text labels.