保存Matlab工作区而不保存或删除图形 [英] Save Matlab workspace without saving or deleting figures

查看:145
本文介绍了保存Matlab工作区而不保存或删除图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

save命令的文档说,如果您不想深入了解*.mat文件,则应删除图形.我定期save*.mat文件,并且在发布clf之后重用我的图形.我希望不必仅将其删除到save*.mat文件中,然后打开一个新图形.有办法吗?

The documentation for the save command says that you should delete figures if you don't want to bog down the *.mat file. I save to a *.mat file periodically, and I re-use my figure after issuing clf. I would prefer not to have to delete it just to save a *.mat file, then open a new figure. Is there a way to do this?

推荐答案

如果知道要保存的所有变量,则可以在调用save时显式保存想要的变量.

You can either save the variables you want explicitly when calling save if you know all the variables you'd like to save.

save('output.mat', 'variable1', 'variable2', 'variable3');

或者,如果要将所有变量保存在 图形不能处理的工作区中,则可以执行以下操作:

Alternately, if you want to save all variables in your workspace that aren't graphics handles, something like this could work:

% Get a list of all variables
allvars = whos;

% Identify the variables that ARE NOT graphics handles. This uses a regular
% expression on the class of each variable to check if it's a graphics object
tosave = cellfun(@isempty, regexp({allvars.class}, '^matlab\.(ui|graphics)\.'));

% Pass these variable names to save
save('output.mat', allvars(tosave).name)

这将不会保存任何图形(或任何图形对象),并使您保持打开状态.

This will not save any figures (or any graphics objects) and also will allow you to keep them open.

这篇关于保存Matlab工作区而不保存或删除图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆