every time you call plot
matlab will clean the canvas before drawing the new function, unless you are focused on a window where you called hold on
, which will substantially tells Matlab to keep the old stuff and superimpose the new drawing.
x = 0:0.001:10
y1 = x.^3;
y2 = 3.^x;
plot(x, y1);
hold on; % without this one will delete y1 before drawing y2
plot(x, y2, 'r');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…