Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
close waitbar after Ctrl-C

Subject: close waitbar after Ctrl-C

From: Gavrilo Bozovic

Date: 11 Jul, 2008 09:58:02

Message: 1 of 5

Hi!

I have a m file that shows a waitbar, during the evaluation
of a long for loop.

As I'm debugging the file, I often have to interrupt the
evaluation using Ctrl-C. When I do this, the waitbar remains
visible, and I can't close it.

Furthermore, with these open "ghost" waitbars, the only way
I found to stop matlab is to kill it.

Does anyone have an idea how to close such instances?

Thanks!!

Subject: close waitbar after Ctrl-C

From: Titus

Date: 11 Jul, 2008 10:03:02

Message: 2 of 5


"Gavrilo Bozovic" <gavrilo.bozovic@helbling.ch> schrieb im Newsbeitrag
news:g57ar9$rro$1@fred.mathworks.com...
> Hi!
>
> I have a m file that shows a waitbar, during the evaluation
> of a long for loop.
>
> As I'm debugging the file, I often have to interrupt the
> evaluation using Ctrl-C. When I do this, the waitbar remains
> visible, and I can't close it.
>
> Furthermore, with these open "ghost" waitbars, the only way
> I found to stop matlab is to kill it.
>
> Does anyone have an idea how to close such instances?
>
> Thanks!!

Hi,
the simplest way to kill those ghosts:

close all force

Titus

Subject: close waitbar after Ctrl-C

From: us

Date: 11 Jul, 2008 10:08:02

Message: 3 of 5

"Gavrilo Bozovic":
<SNIP is waiting forever...

one of the (poor) solutions...

% create a small utility, eg, cw.m

function cw
% H1 line
% help section
     wh=findall(0,'tag','TMWWaitbar');
     delete(wh);
end

% at the command prompt
     waitbar(1,'foo');
     waitbar(1,'goo');
     cw;

us

Subject: close waitbar after Ctrl-C

From: Gavrilo Bozovic

Date: 11 Jul, 2008 10:20:03

Message: 4 of 5

"Titus" <titus.edelhofer@mathworks.de> wrote in message
<g57b4n$ts$1@fred.mathworks.com>...
>
> "Gavrilo Bozovic" <gavrilo.bozovic@helbling.ch> schrieb im
Newsbeitrag
> news:g57ar9$rro$1@fred.mathworks.com...
> > Hi!
> >
> > I have a m file that shows a waitbar, during the evaluation
> > of a long for loop.
> >
> > As I'm debugging the file, I often have to interrupt the
> > evaluation using Ctrl-C. When I do this, the waitbar remains
> > visible, and I can't close it.
> >
> > Furthermore, with these open "ghost" waitbars, the only way
> > I found to stop matlab is to kill it.
> >
> > Does anyone have an idea how to close such instances?
> >
> > Thanks!!
>
> Hi,
> the simplest way to kill those ghosts:
>
> close all force
>
> Titus
>
>

Okay, I learned a new one ;)

It works perfectly for what I need, thanks!


Gavrilo

Subject: close waitbar after Ctrl-C

From: Edric M Ellis

Date: 11 Jul, 2008 12:53:24

Message: 5 of 5

"Gavrilo Bozovic" <gavrilo.bozovic@helbling.ch> writes:

> I have a m file that shows a waitbar, during the evaluation
> of a long for loop.
>
> As I'm debugging the file, I often have to interrupt the
> evaluation using Ctrl-C. When I do this, the waitbar remains
> visible, and I can't close it.
>
> Furthermore, with these open "ghost" waitbars, the only way
> I found to stop matlab is to kill it.
>
> Does anyone have an idea how to close such instances?

An "onCleanup" object (new in R2008a) could help here, like so:

function cleanupWaitbar
    h = waitbar( 0, 'Please wait...' );
    cleanup = onCleanup( @()( delete( h ) ) );

    for ii = 1:100
        pause(ii/100);
        waitbar(ii/100, h);
    end
end

when "cleanup" goes out of scope (either normal exit of the function, or
CTRL-C), it executes the function handle which deletes the waitbar.

See

http://blogs.mathworks.com/loren/2008/03/10/keeping-things-tidy/

for more onCleanup examples.

Cheers,

Edric.

Tags for this Thread

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.

Contact us