필터 지우기
필터 지우기

Using waitbar with tic toc..

조회 수: 2 (최근 30일)
JB
JB 2015년 11월 30일
댓글: Walter Roberson 2015년 11월 30일
Hi, I am trying to display waitbar; i have defined tic @ start of the code and the following code @ end:
end_Time = toc;
a=waitbar(1, 'Please wait ..', 'Working');
for k=tic:end_Time;
waitbar(k, a);
end
% close(a)
But the waitbar is not running in a continuous mode, it runs near the end and vanishes. I want its progress to scynchronise with code running time. Thanks alot.
  댓글 수: 2
Walter Roberson
Walter Roberson 2015년 11월 30일
Why would you want to display a wait bar after the work has already been done??
JB
JB 2015년 11월 30일
I am interested in displaying waitbar when the task starts till it is completed..

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

채택된 답변

Jan
Jan 2015년 11월 30일
The waitbar is fine in your code, but tic and toc fail.
waitH = waitbar(1, 'Please wait ..');
for k = 1 : 10
waitbar(k / 10, waitH);
pause(0.5)
end
delete(waitH )
  댓글 수: 3
JB
JB 2015년 11월 30일
I am reading various files,so the processing time is different depending on the data size present in each file. How can i develop a generic waitbar, that is shown in the time when files are processed, to give a user friendly touch. Many thanks..
Walter Roberson
Walter Roberson 2015년 11월 30일
In order to show in terms of time you would need a prediction for the time it will take to process. But since you have a different amount of time for each, you would need to first have some code that examined the size of each file and used that to estimate the time it would take to process each, and then you would total those estimated sizes and use that in your waitbar calculations
estimated_time = .... whatever it comes out as
begin_time = tic;
for K = 1 : number of files
elapsed_time = toc(begin_time);
waitbar( waitH, elapsed_time / estimated_time );
....
end

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

추가 답변 (0개)

카테고리

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