If you are working in an M-file when you request a plot, and then you continue with more computations, MATLAB ® will generate and display the graphics window and then return immediately to execute the rest of the commands in the program. If you request a second plot, the graph you created will be overwritten. There are two possible solutions to this problem: Use the pause command to temporarily halt the
execution of your M-file program so that you can examine the fi gure, or create a second figure, using the figure function. The pause command stops the program execution until any key is pressed. If you want to pause for a specified number of seconds, use the pause(n) command, which will cause execution to pause for n seconds before continuing.
The figure command allows you to open a new figure window. The next time you request a plot, it will be displayed in this new window. For example, figure(2)opens a window named “Figure 2,” which then becomes the window used for subse-quent plotting. Executing figure without an input parameter causes a new window to open, numbered consecutively one up from the current window. For example, if the current figure window is named “Figure 2,” executing figure will cause “Figure 3” to open. The commands used to create a simple plot are summarized in Table 5.1 .