Bird
0
0

What is wrong with this MATLAB code snippet?

medium📝 Debug Q7 of 15
MATLAB - 2D Plotting
What is wrong with this MATLAB code snippet?
x = 1:4;
y = [5 10 15 20];
plot(x y)
Ay vector must be transposed
BMissing comma between x and y in plot()
Cplot() cannot plot vectors
DVectors x and y have different lengths
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of plot function call

    plot requires arguments separated by commas.
  2. Step 2: Identify missing comma

    Code uses plot(x y) without comma, causing syntax error.
  3. Final Answer:

    Missing comma between x and y in plot() -> Option B
  4. Quick Check:

    Arguments must be comma-separated in plot() [OK]
Quick Trick: Separate plot arguments with commas [OK]
Common Mistakes:
  • Omitting commas between arguments
  • Assuming vectors must be column vectors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes