
There may be times when you need to create multiple figures in matlab. These figures can be used for different purposes, such as to visualize data or show results. To accomplish this, you can use the figure command, the hold on and hold off commands or a combination of these commands.
Creating Multiple Figures In Matlab
The figure command creates a new figure window and sets the figure’s default properties. The resulting figure becomes the current figure for plotting. You can query or modify the figure’s properties after it is created using the f argument. The f argument can be a comma-separated list of name-value pair arguments.
MATLAB also supports a special function that creates a tiled chart layout, containing an invisible grid of tiles over the entire figure. You can then place axes into the layout and plot a figure onto each tile. This function can be called with an output argument to specify the axes. You can then modify the axes’ appearance by setting the corresponding properties.
In this example, you can see that a line graph has been created with a solid blue line and circles for y, a dashed red line with cross signs for v, and a dotted green line and square markers for t. To create a different type of plot, you can also use the subplot command to divide the current figure into an m-by-n grid and add axes based on the position.
The n property specifies the number of rows and columns in a figure. It can be a character vector or a string scalar value. It is usually set to a number in the range of 0 to n.
When a figure is positioned, MATLAB measures the distance from the left edge of the primary display to the left inner edge of the figure window and from the bottom edge of the primary display to the right inner edge of the figure window. This distance can be negative on systems that have more than one monitor. It is also measured relative to the Figure panel within the MATLAB desktop.
Each element in the Position vector is a scalar integer value that specifies the position of the figure in pixels. These pixels are 1/72nd of an inch on Windows systems and 1/96th of an inch on Macintosh systems.
If you want to change the size of a figure, MATLAB calculates its width and height by adjusting the first and second elements of the Position vector. MATLAB then converts the new Position value to equivalent values in the units you specified with the Units property.
Specify optional comma-separated lists of name-value pairs, separated by single quotes (‘ ‘). The names must appear in the order specified with each property.
In addition to naming a figure, you can also specify an RGB triplet or a hexadecimal color code for its background color. The hexadecimal code must be in the range of 0 to 1 and the RGB triplet must contain elements that specify the intensities of the red, green, and blue components.