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:
Step 1: Recall the correct syntax for ylim
The correct syntax requires a two-element vector inside square brackets: ylim([-10 10]).
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.
Final Answer:
ylim([-10 10]) -> Option B
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
Master "2D Plotting" in MATLAB
9 interactive learning modes - each teaches the same concept differently