Bird
0
0

Which of the following is the correct syntax to set the y-axis limits from -10 to 10 in MATLAB?

easy📝 Syntax Q3 of 15
MATLAB - 2D Plotting
Which of the following is the correct syntax to set the y-axis limits from -10 to 10 in MATLAB?
Aylim(-10, 10)
Bylim([-10 10])
Cset(gca, 'YLim', -10, 10)
Daxis([-10 10])
Step-by-Step Solution
Solution:
  1. Step 1: Recall the correct syntax for ylim

    The correct syntax requires a two-element vector inside square brackets: ylim([-10 10]).
  2. Step 2: Identify incorrect options

    ylim(-10, 10) uses parentheses with two arguments which is invalid. set(gca, 'YLim', -10, 10) has wrong set syntax. axis([-10 10]) sets both axes limits, not just y-axis.
  3. Final Answer:

    ylim([-10 10]) -> Option B
  4. Quick Check:

    ylim requires vector input [OK]
Quick Trick: Use square brackets for axis limits vectors [OK]
Common Mistakes:
  • Using parentheses with two arguments
  • Confusing axis and ylim syntax
  • Incorrect set command usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes