0
0
MATLABdata~10 mins

Multiple plots (hold on) in MATLAB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to plot two lines on the same figure.

MATLAB
x = 1:5;
y = x.^2;
plot(x, y);
hold [1];
y2 = x.^3;
plot(x, y2);
Drag options to blanks, or click blank then click option'
Aclear
Bon
Coff
Dall
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hold off' erases the previous plot before drawing the new one.
2fill in blank
medium

Complete the code to plot a sine and cosine on the same graph.

MATLAB
x = linspace(0, 2*pi, 100);
plot(x, sin(x));
hold [1];
plot(x, cos(x));
Drag options to blanks, or click blank then click option'
Aoff
Bclear
Con
Dreset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hold off' causes the first plot to disappear.
3fill in blank
hard

Fix the error in the code to plot two lines without erasing the first.

MATLAB
x = 0:0.1:1;
plot(x, x);
hold [1];
plot(x, x.^2);
Drag options to blanks, or click blank then click option'
Aon
Boff
Cclear
Dhold
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hold off' erases the first plot.
4fill in blank
hard

Fill both blanks to plot three lines on the same figure.

MATLAB
x = 1:4;
plot(x, x);
hold [1];
plot(x, x.^2);
hold [2];
plot(x, x.^3);
Drag options to blanks, or click blank then click option'
Aon
Boff
Chold
Dclear
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hold off' before the second plot clears previous plots.
5fill in blank
hard

Fill all three blanks to create a figure with multiple plots and then release hold.

MATLAB
x = 0:pi/4:2*pi;
plot(x, sin(x));
hold [1];
plot(x, cos(x));
hold [2];
plot(x, tan(x));
hold [3];
Drag options to blanks, or click blank then click option'
Aon
Boff
Chold
Dclear
Attempts:
3 left
💡 Hint
Common Mistakes
Not turning hold off at the end causes all future plots to overlay.