delete variables without deleting gui

3 次查看(过去 30 天)
i design a GUI.... and inside a button i give "clear all" to clear all variables as it takes lots of space... but the gui design tables and static text and axes and all the other design items also gets cleared.... how to clear only variables without clearing the gui design....
  1 个评论
Sara
Sara 2014-5-5
Why don't you just clear your variables by listing them after clear, like
clear var1 var2

请先登录,再进行评论。

采纳的回答

Geoff Hayes
Geoff Hayes 2014-5-5
Elysi - if there are specific variables that you want cleared, then you can clear them by name:
x = zeros(100,100);
y = zeros(1000,33);
z = ones(32,32);
% do some stuff
% clear just x and y only
clear x y;
Type help clear from at the command window for more details.
  4 个评论
Elysi Cochin
Elysi Cochin 2014-5-7
i still didnt get a solution.... how to keep the gui controls and delete all other variables...
Geoff Hayes
Geoff Hayes 2014-5-7
Elysi - please provide a sample of your code that describes where all these variables are coming from i.e. those that you wish to clear, and your use of the clear all command. I still don't understand why you have so many variables that need to be cleared and why you are invoking the clear all command within your code.
Or, you can prefix all of your GUI controls with a gui_ prefix, and then execute the clear command on anything but those variables. For example, in the Command Window type:
clear all; % clear all existing variables and other
x=123; % create five different variables
y=zeros(12,12);
z=cell(1,34);
gui_text1=123.4;
gui_text2=345.3;
Now you can clear all but the gui_ variables with the following command:
clear -regexp ^(?!gui_)\w

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by