Complete the code to plot the vector y against x.
x = 1:5; y = [2, 4, 6, 8, 10]; plot([1], y);
The plot function needs the x-values as the first argument and y-values as the second. Here, x is the vector for the horizontal axis.
Complete the code to add a title to the plot.
x = 1:5; y = [2, 4, 6, 8, 10]; plot(x, y); title([1]);
title.The title function needs a string input to set the plot's title. Here, 'My Plot' is the title text.
Fix the error in the code to plot y versus x with red circles.
x = 1:5; y = [2, 4, 6, 8, 10]; plot(x, y, [1]);
The format string 'ro' tells MATLAB to plot red circles. This fixes the error by specifying the correct marker and color.
Fill both blanks to create a plot of y versus x with blue dashed lines and add an x label.
x = 1:5; y = [2, 4, 6, 8, 10]; plot(x, y, [1]); xlabel([2]);
The plot uses '--b' for blue dashed lines. The xlabel needs a string for the label, here 'X Axis'.
Fill all three blanks to plot y versus x with green stars, add a title, and label the y-axis.
x = 1:5; y = [2, 4, 6, 8, 10]; plot(x, y, [1]); title([2]); ylabel([3]);
The plot uses 'g*' for green stars. The title and y-axis label need strings: 'My Green Plot' and 'Y Axis'.