Documentation

openfig

Open figure saved in FIG-file

Syntax

  • openfig(filename) example
  • openfig(filename,copies)
  • openfig(___,visibility) example
  • fig = openfig(___)

Description

example

openfig(filename) opens the figure saved in the MATLAB® figure file (FIG-file) called filename.

openfig(filename,copies) specifies whether to open a new copy of the figure in the case that a copy is already open. If you do not want to create a new copy, set copies to 'reuse'. The 'reuse' option brings the existing figure to the front of the screen. To open a new copy of the figure regardless of whether a copy is already open, set copies to 'new' . The 'new' option is the default behavior.

example

openfig(___,visibility) specifies whether to open the figure in a visible or invisible state. To display the figure, set visibility to 'visible'. If you do not want to display the figure, use the 'invisible' setting. You can use this option with any of the input argument combinations in the previous syntaxes.

fig = openfig(___) returns the figure object. Set properties of the figure object to modify its appearance or behavior. For a list of properties, see Figure Properties.

Examples

collapse all

Open Figure Saved in MATLAB Figure File

Create a surface plot and save the figure as a MATLAB figure file. Then, close the figure.

surf(peaks)
savefig('MySavedPlot.fig')
close(gcf)

Open the saved figure.

openfig('MySavedPlot.fig')

Open Invisible Figure in Visible State

Create a surface plot and make the figure invisible. Then, save the figure as a MATLAB figure file. Close the invisible figure.

surf(peaks)
set(gcf,'Visible','off')
savefig('MySavedPlot.fig')
close(gcf)

Open the saved figure and make it visible on the screen.

openfig('MySavedPlot.fig','visible')

Input Arguments

collapse all

filename — File name of saved figurestring

File name of saved figure, specified as a string. You do not have to specify the full file path, as long as it is on your MATLAB path. Including .fig in the file name is optional.

Example: openfig('MySavedFigure.fig')

copies — Control for opening multiple copies of figure'new' (default) | 'reuse'

Control for opening multiple copies of the figure, specified as one of these values:

  • 'new' — Open a new copy of the figure, even if a copy already exists on the screen.

  • 'reuse' — Open a new copy of the figure only if one does not exist. If a copy exists, then bring the existing copy to the front of the screen. If the figure is off the screen, then 'reuse' repositions the figure so that it is completely on the screen. This option helps provide compatibility with different screen sizes and resolutions by ensuring that the figure displays on screen.

Example: openfig('MySavedFigure.fig','reuse')

visibility — Figure visibility'visible' | 'invisible'

Figure visibility, specified as one of these values:

  • 'visible' — Open the saved figure in a visible state. If the MATLAB figure file contains an invisible figure, then you can use this option to make the figure visible when it opens.

  • 'invisible' — Open the saved figure in an invisible state.

Example: openfig('MySavedFigure.fig','invisible')

Output Arguments

collapse all

fig — Figure objectfigure object

Figure object. Set properties of the figure to change the appearance or behavior of the opened figure. For a list of properties, see Figure Properties.

Limitations

  • Do not use openfig to open FIG-files created with GUIDE. Use the guide function instead.

See Also

| |

Introduced before R2006a

Was this topic helpful?