0
0
MATLABdata~5 mins

plot() function basics in MATLAB - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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)?
Aplot([1 2 3], [1 4 9], 'k.')
Bplot([1 2 3], [1 4 9], 'r--')
Cplot([1 2 3], [1 4 9], 'b-')
Dplot([1 2 3], [1 4 9], 'g:')
What does plot(x, y) do if x is omitted and only plot(y) is called?
APlots y against its index values starting at 1
BThrows an error
CPlots y against zeros
DPlots y against random values
How do you keep multiple plots visible on the same figure?
AUse <code>hold on</code>
BUse <code>hold off</code>
CCall <code>plot()</code> multiple times without any command
DUse <code>clear</code>
Which command adds a title to a plot?
Axlabel('My Plot')
Blegend('My Plot')
Cylabel('My Plot')
Dtitle('My Plot')
What is the output of plot([1 2 3], [4 5 6], 'ko')?
ARed dashed line connecting points
BBlack circle markers at points without connecting lines
CBlack solid line connecting points
DBlue dotted line connecting points
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.