How to use hold on in matlab?
In the first step, we first need to know that hold on is mainly used to retain the current drawing when adding a new drawing. Enter the help hold command in the command line window and you can see the introduction, as shown in the figure below:
In the second step, let’s use hold on, create an m file, and enter the
“ x=1:10; y=[1 3 5 7 7 8 8 10 15 18] plot(x,y,'-*') hold on x1=1:10; y1=[1 2 3 4 5 6 7 9 15 18] plot(x1,y1,'-*') ”
code, as shown below:
The third step is to run the m file. You can see that two lines are drawn on one image. hold on is mainly used when drawing multiple lines, as shown in the following figure:
In the fourth step, we can also look at the image of drawing multiple lines without using hold on, as shown below:
After running the m file in the fifth step, you can see that only the latest line is drawn, as shown below:
The above is the detailed content of How to use hold on in matlab. For more information, please follow other related articles on the PHP Chinese website!