Bird
0
0

Which of the following is the correct syntax to plot y versus x in MATLAB?

easy📝 Syntax Q12 of 15
MATLAB - 2D Plotting
Which of the following is the correct syntax to plot y versus x in MATLAB?
Aplot(x:y)
Bplot(y, x)
Cplot(x, y)
Dplot(x + y)
Step-by-Step Solution
Solution:
  1. Step 1: Recall the syntax of plot()

    The correct syntax to plot y versus x is plot(x, y), where x and y are vectors of the same length.
  2. Step 2: Check other options

    plot(y, x) reverses the order, plotting x versus y, which is incorrect. plot(x:y) uses a colon operator incorrectly. plot(x + y) tries to plot the sum, which is invalid.
  3. Final Answer:

    plot(x, y) -> Option C
  4. Quick Check:

    plot(x, y) = correct syntax [OK]
Quick Trick: Always put x first, then y in plot() [OK]
Common Mistakes:
  • Swapping x and y arguments
  • Using colon operator inside plot()
  • Trying to plot sums instead of vectors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes