Avoid saving graphics in Matlab
Launching R2014b Matlab changed the way of saving variables using the command save
; Matlab also changed the way graphics descriptors are stored, they are now saved as structures. If you have graphic pens in the workspace, Matlab takes longer to save the file mat
, the math file size is large, and when you load the file, all the saved numbers have slipped out, which annoys me. It also issues a warning:
Warning: Figure is saved in Oakley_19_PDEparameterEstimation.mat. Saving graphics handle variables can cause the creation
of very large files. To save graphics figures, use savefig.
I have a simple and straightforward question:
How can I avoid saving all graphics descriptors?
Please do not suggest that I can clearvars
draw shapes before saving them.
thank
source to share
You can get information about the current workspace variables by using whos
and save only those variables whose class is not a graphical descriptor object (i.e. the class name string does not include 'matlab.graphics'
or 'matlab.ui'
):
varData = whos; saveIndex = cellfun(@isempty, regexp({varData.class}, 'matlab.(graphics|ui)')); saveVars = {varData(saveIndex).name}; save('no_handles.mat', saveVars{:});
source to share