How can a process bar/wait bar run during a function is running

Hello, am running a code and I want to add a waitbar during a function is running, this function takes a lot of time but the problem is that the waitbar is updating after the function execution.
Here is the code:
h = waitbar(0,'Please wait...');
x1= ode3(F,tspan, xi');
for step = 1:0.008:time
waitbar(step /time)
end
close(h)

 採用された回答

Jan
Jan 2018 年 1 月 17 日

0 投票

Think twice: How can the waitbar get information about the current level of progress? Therefore it must get data from inside your ode3(). So insert the code for updating the waitbar inside this function. If this is not possible, e.g. because it is an external or built-in function, all you can do is to display a static message, which informs the user about a long running process.
If "ode3" means one of the built-in integrators, the OutputFcn ist a good choice: There you have the current value of the time. This need not be proportional to the elapsed time, but it is a rough hint about the progress.

1 件のコメント

iacovos stylianou
iacovos stylianou 2018 年 1 月 17 日
Thanks a lot. I updated the waiitbar inside the ode3 function and is working now.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDialog Boxes についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by