필터 지우기
필터 지우기

waitbar or progress bar without using for loop

조회 수: 13 (최근 30일)
Mahdi
Mahdi 2016년 7월 4일
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
Mahdi
Mahdi 2016년 7월 4일
@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 2016년 7월 4일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 7월 4일
"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
Othmane ELMOUATAMID
Othmane ELMOUATAMID 2020년 4월 13일
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.
Saripaka Venkata Sai Prasanth
Saripaka Venkata Sai Prasanth 2020년 6월 4일
Thank you Othmane Elmouatamid.
I had been trying for this implementation and it helped a lot.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by