From: Mark on
Hi!

In a for-loop, I would like to use a waitbar like the standard Matlab waitbar with a cancel button, but good looking. There are some better waitbars in the file exchange, but none of them seem to have a cancelbutton with them. I want my user to:

- See the progress the program is making
- Be able to stop the program by clicking 'cancel' or 'abort'.

For example, I found this workbar:

http://www.mathworks.com/matlabcentral/fileexchange/7109-workbar

Can anyone help me with creating a cancel button on this or another waitbar, making it possible to kill the program by clicking on it?

Thanks in advance for all responses!
From: Jurn on
On May 11, 5:09 pm, "Mark " <markmat...(a)gmail.com> wrote:
> Hi!
>
> In a for-loop, I would like to use a waitbar like the standard Matlab waitbar with a cancel button, but good looking. There are some better waitbars in the file exchange, but none of them seem to have a cancelbutton with them. I want my user to:
>
> - See the progress the program is making
> - Be able to stop the program by clicking 'cancel' or 'abort'.
>
> For example, I found this workbar:
>
> http://www.mathworks.com/matlabcentral/fileexchange/7109-workbar
>
> Can anyone help me with creating a cancel button on this or another waitbar, making it possible to kill the program by clicking on it?
>
> Thanks in advance for all responses!

I use a variable to check if I still need to run, so

is_aborted = false;

for i=1:100
if is_aborted
break
end

% do stuff %

end

When I hit my abort button my is_aborted is changed into true. The
program will stop at the next iteration.

I didn't check the source of your workbar, but i think you will be
able to add a pushbutton and a callback for the button.

Good luck