Bird
0
0

Identify the error in the following MATLAB code:

medium📝 Debug Q6 of 15
MATLAB - 2D Plotting
Identify the error in the following MATLAB code:
plot(1:10, rand(1,10));
axis([0 10]);
ANo error, code runs fine
Bplot function has wrong input sizes
Crand function should have two arguments
Daxis command requires four values for limits
Step-by-Step Solution
Solution:
  1. Step 1: Check axis command syntax

    axis expects four values: [xmin xmax ymin ymax]. Here only two values are given.
  2. Step 2: Verify other parts

    Plot inputs are correct sizes, rand(1,10) is valid, so no error there.
  3. Final Answer:

    axis command requires four values for limits -> Option D
  4. Quick Check:

    axis needs four limits [OK]
Quick Trick: axis needs [xmin xmax ymin ymax] four values [OK]
Common Mistakes:
  • Passing only two values to axis
  • Misunderstanding rand arguments
  • Ignoring axis syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes