I want to edit a certain property of MATLAB figures saved as .fig (MATLAB's default format) files.
I create a lot of graphics-intensive figures in a script, so I choose not to display them by making the default figure invisible with set(0,'DefaultFigureVisible','off')
. This sets the 'Visible'
property of any new figure to 'off'
. This way I can create, edit, save, etc., figures without the need to draw them, which can be taxing on CPU, GPU and their memories. I save the figures as .fig files using the saveas(handle,'filename.fig')
command. This also saves the 'Visible'
property, which is a problem when I do want to open the figure (e.g. by double-clicking the file in my Windows Explorer). It loads the figure, but it doesn't display it because its 'Visible'
property is set to 'off'
.
I want all .fig files to be saved with the property set to 'on'
, but how can I achieve this without displaying (= taxing) the figures? The moment I use set(handle,'Visible','on')
, the figure is drawn.
So basically, I want to edit the file on a lower level than when it's loaded as a figure in MATLAB.
I think it could be done as follows, but I do not know exactly how to achieve it. One can load the .fig's data as if it were a .mat file using s=load('filename.fig','-mat');
. This loads a structure s
containing some fields that contain all the figure's data, properties, etc. Now, the figure handle must be found in this unkown structure and the 'Visible'
property that goes along with the handle edited.
Can this be done without the figure being drawn?
I tried, but haven't succeeded, using fopen
, fread
and their friends.
Does anybody know how to do what I want to do?