MATLAB Answers

waitbar in GUI (by pushing a button to run a m-file)

16 views (last 30 days)
I have a m-file and now I want to make a GUI for it. In this m-file there is a For-loop that contains a waitbar that you can see below:
h=waitbar(0,'Please wait','Name','Inputs');
for o = 1:N %N is defined before
waitbar(o/N,h);
end
Now, how could this waitbar be shown inside the gui (not in another windows and not outside the gui) by pushing a button for running thid code?

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 7 Aug 2012
waitbar() always creates a new figure to display the bar in.
You can examine the waitbar code and adapt it for your own needs (calling the result something else!)

  3 Comments

mohammad
mohammad on 7 Aug 2012
Thanks Walter. I saw some codes in File Exchange that have waitbar inside GUI. like this one: http://www.mathworks.com/matlabcentral/fileexchange/23838-ledbar-a-fast-and-simple-embedded-progress-bar-without-axes
But I couldn't use this in my own GUI because my information about GUI is too low. I'll be thanks so much if you help me.
Walter Roberson
Walter Roberson on 8 Aug 2012
That code creates a new figure.
If you have a restriction that does not allow you to create a new figure for the waitbar(), then you should list what other restrictions you have. For example, is it okay if we clear the existing figure and put the waitbar in it?
mohammad
mohammad on 8 Aug 2012
Walter, thanks for reply. I mean its be nice if the waitbar be shown on the same gui windows that I run the m-file from that gui. (On this gui there is a push-button for running that m-file and under this push-button I want a waitbar to be shown the progress of running this m-fi.)

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags