MATLAB tip of the day: Invisible figures

Problem

MATLAB *.fig files won't open.

Key Symptoms

  • when double-clicking on a *.fig file in a folder, no figure is shown in MATLAB; e.g. on a Mac, after double-clicking the file, you see the opening animation, but no signs in MATLAB that the file actually opened
  • no error message is displayed in the MATLAB Command Window
  • after an unsuccessful attempt to open a figure file, entering figure into the Command Window produces a new figure window labeled Figure 2 (or greater), not Figure 1
  • figures made previously open normally
  • affected figures do not open on other instances of MATLAB

Cause

About the time your figures stopped showing up, you probably turned off figure visibility. Setting figures invisible by default sets the figures invisible, including the files saved. That is, it's not a switch for the display of figures, it's a switch for the figures themselves.

Solution

There are several ways to make those figures visible again, but my favorite solution (to a problem that I don't think should exist in the first place) is to make a copy of the openfig function, and change the line for the default behavior (which is set to respect the visibility status of the figure file) to visible. Save that customized openfig function to your MATLAB directory, and you're all set.

Before I found this answer, I was despairing that I'd have to remake dozens of *.fig files that wouldn't open. When I saw this page, I realized that I had encountered (and corrected) this problem once before. To save myself – and whoever else comes across this post – some heartache, I decided to write it up.