Bird
0
0

You want to plot three different data sets on the same figure with different colors and then reset plotting to default for future plots. Which sequence of commands is correct?

hard📝 Application Q15 of 15
MATLAB - 2D Plotting
You want to plot three different data sets on the same figure with different colors and then reset plotting to default for future plots. Which sequence of commands is correct?
Aplot(x1, y1, 'r'); plot(x2, y2, 'g'); plot(x3, y3, 'b'); hold on; hold off;
Bhold on; plot(x1, y1, 'r'); plot(x2, y2, 'g'); plot(x3, y3, 'b');
Cplot(x1, y1, 'r'); hold on; plot(x2, y2, 'g'); plot(x3, y3, 'b'); hold off;
Dplot(x1, y1, 'r'); hold off; plot(x2, y2, 'g'); hold on; plot(x3, y3, 'b');
Step-by-Step Solution
Solution:
  1. Step 1: Use hold on after first plot to combine multiple plots

    After plotting the first data set, hold on keeps the figure active for additional plots.
  2. Step 2: Plot all data sets with specified colors and then reset with hold off

    Plotting the second and third data sets adds them to the same figure. Calling hold off resets plotting behavior for future plots.
  3. Final Answer:

    plot(x1, y1, 'r'); hold on; plot(x2, y2, 'g'); plot(x3, y3, 'b'); hold off; -> Option C
  4. Quick Check:

    hold on after first plot, hold off after last plot [OK]
Quick Trick: hold on after first plot, hold off after last [OK]
Common Mistakes:
  • Not calling hold off after multiple plots
  • Calling hold on before first plot
  • Mixing hold on and hold off incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes