How to use hold on in matlab
Editor to share with you how to use hold on in matlab. I hope you will gain a lot after reading this article. Let's discuss it together.
How to use hold on in matlab?
In the first step, we need to know that hold on is mainly used to add new drawings to retain the current drawing. Enter the help hold command in the command line window, and you can see the introduction, as shown in the following figure:
In the second step, let's use hold on, create an m file, and type
"hold onx1=1:10;y1= hold onx1=1:10;y1= [1 2 3 4 5 5 6 7 9 15 18] plot (x 1 7 7 8 8 10 15 18)"
Code, as shown in the following figure:
The third step is to run the m file, and 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 take a look at the image of drawing multiple lines without using hold on, as shown in the following figure:
After running the m file in step 5, you can see that only the latest line is drawn, as shown in the following figure:
After reading this article, I believe you have a certain understanding of the use of hold on in matlab, want to know more about it, welcome to follow the industry information channel, thank you for reading!