Waitbar real time

5 ビュー (過去 30 日間)
alexis
alexis 2011 年 12 月 20 日
編集済み: Scotty Neally 2020 年 7 月 21 日
How can Matlab run a sciprt but user to see only a waitbar. For example my script it's over after 2 min and the user care only for the output excel. I want to create a waitbar which will be in real time...(25% at 30s, 50% at 1mn, 75% at 1.5min,..) Can you help me pls??

回答 (3 件)

Robert Cumming
Robert Cumming 2011 年 12 月 20 日
help timer
help waitbar
  3 件のコメント
Robert Cumming
Robert Cumming 2011 年 12 月 20 日
I've pointed you in the direction of the 2 functions you need to solve your problem. Have a look at the help and the examples (plus any FEX that Titus linked you to).
Once you've tried some coding if its still not working come back with some detailed questions on your specific code.
alexis
alexis 2011 年 12 月 21 日
Thanks.Hope i can do that.

サインインしてコメントする。


Titus Edelhofer
Titus Edelhofer 2011 年 12 月 20 日
It all depends on your estimate on how much already has been done. Robert noted already the relevant functions: start a timer. In the timer function you update the waitbar (function waitbar). This is pretty straight forward. One of two things need to be done though: either your script needs to update something such that the timer knows how much has already been done. Or, you need an estimate about how long your script will be running.
Take a look at the file exchange for various waitbar enhancements ...

Scotty Neally
Scotty Neally 2020 年 7 月 21 日
Modify this code to suit your needs:
t = timer('TimerFcn', 'stat=false; disp(''Timer Done!'')','StartDelay',10);
start(t);
stat=true;
count = 0;
f = waitbar(0,'Start');
while(stat==true)
count = count + 1;
f = waitbar(count/10,f,[num2str(10-count),' sec remaining']);
pause(1);
end
delete(t);
delete(f);
  1 件のコメント
Scotty Neally
Scotty Neally 2020 年 7 月 21 日
編集済み: Scotty Neally 2020 年 7 月 21 日
Or alternatively put the waitbar execution within the timer:
f = waitbar(0,'Start');
count = -1;
t = timer('TimerFcn', 'count = count + 1;f = waitbar(count/10,f,[num2str(10-count),'' sec remaining'']);','ExecutionMode','fixedDelay','Period',1);
start(t);
pause(10);
stop(t);
delete(t);
delete(f);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDialog Boxes についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by