waitbar or progress bar without using for loop

Hello everybody,
In my code, I have to call different number (it varies regarding to the user input in the GUI of the code) of data set from a sql data bank. Some times it could take 2 min or 5 min. most of suggestions in Answer segment or file exchange were reagrding to the application of waitbar in a for loop. But, there isn't any for loop im my code.
I tried to use tic, toc functions. Before calling the first data, I wrote 'tic' and after each call of sql data 'toc'. But I need the final performed time, which is unknown before finishing the whol process, to make a time fraction. Does anyone have a suggestion?
other question: if illustation of remaining would not possible for the described case, how can i show the preformed time after each Call of data set through a processbar. I mean:
tic;
call the first data set;
toc;
show the time in waitbar
call the second data set;
toc
show the time in the same waitbar
...
call the nth data set;
toc
show the time in the same waitbar

4 comentarios

José-Luis
José-Luis el 4 de Jul. de 2016
How about just leaving the first tic and the last toc?
Stephen23
Stephen23 el 4 de Jul. de 2016
@Mahdi: why not turn it into a loop? The code you have described sounds just like what happens in a loop. It might be quite easy to code a loop to do the same thing.
Mahdi
Mahdi el 4 de Jul. de 2016
@José-Luis: because the user want to see the required time for each calling. Actually he want to know how,long should he wait for calling all required data.
José-Luis
José-Luis el 4 de Jul. de 2016
Well, if you know the number of datasets you will be loading you can give an estimate using the average of the time it has taken until now.
You could probably make that prediction more accurate using the size of the files you are loading. Looking at a file's size might be considerably faster than loading it to memory.

Iniciar sesión para comentar.

Respuestas (1)

"waitbar() creates a figure. In R2016a (did not check other HG2 implementations), that figure has a hidden member in Children which is a JavaWrapper . That JavaWrapper has a JavaPeer which is a javax.swing.JProgressBar which is what is doing the real work."
wb = waitbar(0, 'Your Message Here');
wbch = allchild(wb);
jp = wbch(1).JavaPeer;
and jp will be the javax.swing.JProgressBar
That JProgressBar has a method setIndeterminate . If you set it true
jp.setIndeterminate(1)
"An indeterminate progress bar continuously displays animation indicating that an operation of unknown length is occurring"
However...
"Some look and feels might not support indeterminate progress bars; they will ignore this property. "
It looks like my OS-X system is not animating the progress bar... or I missed something in the implementation.

3 comentarios

Mahdi
Mahdi el 4 de Jul. de 2016
@ Walter: Thank you for the description. If I understand your comment correcly, your described the command SetIndeterminant(true) that would work like a busy GUI. I already wrote the busy GUI in the my code as following. however, I cannot show the show how lang should he wait:
BusyHnadle=BusyGUI;
drawnow;
.... starting to call sql data ....
.... end of calling sql data ....
busyHandle.symbole.stop;
busyHandle.symbole.setBusyText('all done!');
pause(0.4);
delete(busyHandle.figure1);
Thank you Walter for your answer, this helped me to create an indeterminate progress bar for Matlab 2016b.
I used it this way to keep the user away from Command Window while my code is running in the backgroud :
wb = waitbar(0, 'Pease wait ...','WindowStyle', 'modal');
wbch = allchild(wb);
jp = wbch(1).JavaPeer;
jp.setIndeterminate(1);
% ====== %
% my code here
% ====== %
close(wb);
Just in case someone needed it.
I found in the documentation that Maltab 2020a provides that in a easy way uiprogressdlg.
Thank you Othmane Elmouatamid.
I had been trying for this implementation and it helped a lot.

Iniciar sesión para comentar.

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Preguntada:

el 4 de Jul. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by