Thread Subject: gui push button

Subject: gui push button

From: Eli Chmouni

Date: 2 Jul, 2009 19:09:02

Message: 1 of 6

I have a gui and i want the code that i need to add to a gui push button to clear all the variables from the workspace.

Subject: gui push button

From: ImageAnalyst

Date: 2 Jul, 2009 19:41:48

Message: 2 of 6

On Jul 2, 3:09 pm, "Eli Chmouni" <echmo...@gmail.com> wrote:
> I have a gui and i want the code that i need to add to a gui push button to clear all the variables from the workspace.

------------------------------------------------------
Which workspace? In addition to the "global" workspace, the callback
function of the button has it's own workspace with its own local
scoped variables. You can use "clear all" to clear these local
variables, but it seems risky since some variables are input arguments
of the callback routine. If you want to delete some variables in the
"global" workspace I think you might have to declare them with the
global command in your callback first so that the "clear" command can
see them. There might be another way that I don't know about though.

Subject: gui push button

From: Nathan

Date: 2 Jul, 2009 19:45:24

Message: 3 of 6

On Jul 2, 12:09 pm, "Eli Chmouni" <echmo...@gmail.com> wrote:
> I have a gui and i want the code that i need to add to a gui push button to clear all the variables from the workspace.

handle = uicontrol('Style','pushbutton','String','Clear',...
'Units','normalized','Position',[.25 .25 .5 .5],'Callback','clear');

It's simpler using GUIDE, but there's some code for you to mess around
with.

-Nathan

Subject: gui push button

From: Eli

Date: 2 Jul, 2009 19:59:10

Message: 4 of 6

On Jul 2, 12:45 pm, Nathan <ngrec...@gmail.com> wrote:
> On Jul 2, 12:09 pm, "Eli Chmouni" <echmo...@gmail.com> wrote:
>
> > I have a gui and i want the code that i need to add to a gui push button to clear all the variables from the workspace.
>
> handle = uicontrol('Style','pushbutton','String','Clear',...
> 'Units','normalized','Position',[.25 .25 .5 .5],'Callback','clear');
>
> It's simpler using GUIDE, but there's some code for you to mess around
> with.
>
> -Nathan

Hello Nathan
yes i am using Guide and i created a push button but i cannot figure
out the code that i need to write in the push button callback . I have
variable values in the matlab workspace and i want to clear them . If
i was using the command window i would just write clear so i need that
code that performs the same operation from a push button in the gui
thx




Subject: gui push button

From: Nathan

Date: 2 Jul, 2009 20:07:34

Message: 5 of 6

On Jul 2, 12:59 pm, Eli <echmo...@gmail.com> wrote:
> On Jul 2, 12:45 pm, Nathan <ngrec...@gmail.com> wrote:
>
> > On Jul 2, 12:09 pm, "Eli Chmouni" <echmo...@gmail.com> wrote:
>
> > > I have a gui and i want the code that i need to add to a gui push button to clear all the variables from the workspace.
>
> > handle = uicontrol('Style','pushbutton','String','Clear',...
> > 'Units','normalized','Position',[.25 .25 .5 .5],'Callback','clear');
>
> > It's simpler using GUIDE, but there's some code for you to mess around
> > with.
>
> > -Nathan
>
> Hello Nathan
> yes i am using Guide and i created a push button but i cannot figure
> out the code that i need to write in the push button callback . I have
> variable values in the matlab workspace and i want to clear them . If
> i was using the command window i would just write clear so i need that
> code that performs the same operation from a push button in the gui
> thx

All you put in the Callback is 'clear'. That is the code. I don't know
what's got you so confused...

Clear is the command. It works in m-files as well as in the command
window.

Give it a try.
-Nathan

Subject: gui push button

From: ImageAnalyst

Date: 3 Jul, 2009 01:29:12

Message: 6 of 6

Again, you need to understand what I responded first. What Nathan
said will only clear the local scope variables that exist ONLY within
that button's callback. It will not clear any other variables in any
other workspace, which means that it won't clear anything in the
global workspace either. I know - I just tested this to verify it. I
put a clear in the callback and it cleared only the local variables
and those in the global workspace remained untouched. If that's what
you want, then fine, you're done, no problem. I just mention this
because it appears that you don't have a complete understanding of
what "workspace" entails.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
gui Eli Chmouni 2 Jul, 2009 15:14:02
clear Eli Chmouni 2 Jul, 2009 15:14:02
push Eli Chmouni 2 Jul, 2009 15:14:02
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com