matlab hold
时间: 2023-10-01 12:10:55 浏览: 90
图用hold命令-MATLAB编程入门
The "hold" command in MATLAB is used to retain the current plot and add new plots to the same axes. It is commonly used when creating multiple plots on the same figure window.
When "hold on" is used, MATLAB will not clear the previous plot and will keep the current plot on the axes. This allows additional plots to be added to the same window without overwriting the previous plot.
When "hold off" is used, MATLAB will clear the axes and any new plot will be displayed as a new plot.
For example, consider the following code:
x = 0:0.1:2*pi;
y1 = sin(x);
y2 = cos(x);
plot(x,y1)
hold on
plot(x,y2)
In this code, the first plot will be of the sine function, and the "hold on" command will retain the plot. The second plot will be of the cosine function and will be added to the same window. If "hold off" was used before the second plot command, the cosine plot would be displayed in a new window.
阅读全文