Bird
0
0

Consider this MATLAB code:

medium📝 Predict Output Q5 of 15
MATLAB - 2D Plotting
Consider this MATLAB code:
t = 0:0.2:1;
plot(t, sin(2*pi*t));
hold on;
plot(t, cos(2*pi*t));
hold off;
plot(t, t);

What will be displayed in the figure window?
AOnly the sin and cos plots are visible, line plot erased.
BOnly the line plot of t vs t is visible.
CAll three plots (sin, cos, and line) are visible together.
DAn error occurs due to <code>hold off</code> usage.
Step-by-Step Solution
Solution:
  1. Step 1: Plot sin and cos with hold on

    The first two plots (sin and cos) appear together because of hold on.
  2. Step 2: hold off disables hold, so next plot replaces all previous plots

    After hold off, the last plot(t, t) clears the figure and shows only the line plot.
  3. Final Answer:

    Only the line plot of t vs t is visible. -> Option B
  4. Quick Check:

    hold off clears previous plots = C [OK]
Quick Trick: Use hold off to reset plot before new plot [OK]
Common Mistakes:
  • Assuming all plots remain after hold off
  • Expecting error from hold off
  • Confusing hold on and hold off effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes