Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a title to the plot.
MATLAB
plot(x, y)
title([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the title text in quotes.
Using xlabel instead of title.
✗ Incorrect
The title function requires the title text as a string, so it must be in quotes.
2fill in blank
mediumComplete the code to label the x-axis.
MATLAB
plot(x, y)
xlabel([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the label text.
Passing a variable name instead of a string.
✗ Incorrect
The xlabel function needs the label as a string, so it must be in quotes.
3fill in blank
hardFix the error in the code to add a legend.
MATLAB
plot(x, y1, x, y2)
legend([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of curly braces.
Passing a single string with commas instead of a cell array.
✗ Incorrect
The legend function expects a cell array of strings, which in MATLAB is created with curly braces {}.
4fill in blank
hardFill both blanks to add labels and a title to the plot.
MATLAB
plot(x, y) xlabel([1]) title([2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes for the labels.
Swapping xlabel and title.
✗ Incorrect
Both xlabel and title require string inputs, so the labels must be in quotes.
5fill in blank
hardFill all three blanks to add labels, title, and legend to the plot.
MATLAB
plot(x, y1, x, y2) xlabel([1]) title([2]) legend([3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets for legend labels.
Not quoting xlabel or title text.
✗ Incorrect
xlabel and title require strings in quotes, and legend requires a cell array of strings using curly braces.