Recall & Review
beginner
What is the basic purpose of the
plot() function in MATLAB?The
plot() function is used to create 2D line plots to visualize data points connected by lines.Click to reveal answer
beginner
How do you plot the points (1,2), (2,4), and (3,6) using
plot()?Use
plot([1 2 3], [2 4 6]) to plot x-coordinates [1 2 3] against y-coordinates [2 4 6].Click to reveal answer
intermediate
What does the command
plot(x, y, 'r--') do?It plots the data points with a red dashed line connecting them. 'r' means red color, '--' means dashed line style.
Click to reveal answer
beginner
How can you add labels to the x-axis and y-axis in a plot?
Use
xlabel('label') and ylabel('label') to add text labels to the x-axis and y-axis respectively.Click to reveal answer
intermediate
What happens if you call
plot() multiple times without hold on?Each new
plot() call clears the previous plot, so only the last plot is visible unless you use hold on.Click to reveal answer
Which command plots a blue solid line connecting points (1,1), (2,4), and (3,9)?
✗ Incorrect
The 'b-' option means blue solid line. Other options specify different colors or line styles.
What does
plot(x, y) do if x is omitted and only plot(y) is called?✗ Incorrect
If only y is given, MATLAB plots y values against their indices (1, 2, 3, ...).
How do you keep multiple plots visible on the same figure?
✗ Incorrect
hold on keeps the current plot so new plots add to it instead of replacing.Which command adds a title to a plot?
✗ Incorrect
title() adds a title above the plot.What is the output of
plot([1 2 3], [4 5 6], 'ko')?✗ Incorrect
'k' means black color, 'o' means circle markers, no line style means no connecting lines.
Explain how to create a simple 2D line plot in MATLAB using the
plot() function.Think about how you give x and y points to <code>plot()</code>.
You got /3 concepts.
Describe how to customize the color and style of a plot line using the
plot() function.Use a string like 'r--' to set red dashed lines.
You got /3 concepts.