Bird
0
0

What will be the output of the following MATLAB code?

medium📝 Predict Output Q13 of 15
MATLAB - 2D Plotting
What will be the output of the following MATLAB code?
t = 0:0.1:1;
plot(t, t);
hold on;
plot(t, t.^2);
ATwo plots will appear: a straight line and a curve on the same figure.
BOnly the plot of t vs t^2 will be shown.
CAn error will occur because hold on is used incorrectly.
DOnly the plot of t vs t will be shown.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the first plot command

    The first plot draws a straight line y = t on the figure.
  2. Step 2: Understand the effect of hold on and second plot

    Using hold on keeps the first plot visible, so the second plot y = t^2 is drawn on the same figure as a curve.
  3. Final Answer:

    Two plots will appear: a straight line and a curve on the same figure. -> Option A
  4. Quick Check:

    hold on keeps previous plot, so both appear [OK]
Quick Trick: hold on keeps old plots visible for new ones [OK]
Common Mistakes:
  • Thinking only last plot shows
  • Assuming hold on causes error
  • Confusing plot commands order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes