How can I open a specific figure from 'file.fig'?
4 views (last 30 days)
Show older comments
I have 'file.fig' contains about 500 figures I would like to open just one specific figure like number 200, without open all, How can I do that?
Thanks in advance,
Riyadh
5 Comments
Walter Roberson
on 4 Jun 2016
I was replying to Azzi showing how it is possible to save multiple figures in the same .fig
Answers (1)
Walter Roberson
on 3 Jun 2016
I have just gone through the code, and the answer is NO.
Loading a .fig file is done by using load() on the .fig file, which is really a .mat file in disguise. The load() is the built-in routine that cannot be accessed, and it goes through and recreates all of the figures. It does this in the course of loading a single structure. In current .fig files, the structure name is hgM_070000 where the number might be different for older versions (it is a MATLAB version number); for some older .fig files, the structure name is hgS followed by a version number. One of the graphics objects stored in a field has the figures stored in it.
I thought about the possibility of using matFile to be selective about what is loaded from the .fig file, but you might recall that matFile does not allow one to be selective about which fields of a structure are loaded.
The closest that I can see to do: in R2014b or later, if you add an InstanceCreated listener to the metaclass of matlab.ui.Figure then the listener will fire for each figure created; you could potentially check each one as it was created and delete each if it wasn't the one you were interested in (though clearing it instead of deleting it might be needed to have everything else work out.)
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!