How to display a running timer in MATLAB Design App

39 ビュー (過去 30 日間)
polo sepian
polo sepian 2020 年 1 月 26 日
コメント済み: Mohammad Sami 2020 年 1 月 26 日
Dear Coder, I have design a simple app using App Design. The App supposed to show a time lapse while some other activity are running simultanously. Other thread have discussed about the implementation of time lapse under App design by the Design App such as link or link.
However, im still unable to replicate the solution given in these thread.
Hence, I tried something like below,
while app1.StarttimelapseButton.Value==1
T2 = clock;
time_elapsed = etime(T2,T1);
app1.TimeLapseEditField.Value=sprintf('%.6f',time_elapsed );
drawnow
end
% Next lines
% Function responsible for the execution of the "Other activity"
However, the code execution stuck in the while loop if using the above code.
May I know how to implement a timer in AppDesigner. The m and mlapp files that I created can be found this link.
Thanks in advance for the time to entertain this problem
  4 件のコメント
Mohammad Sami
Mohammad Sami 2020 年 1 月 26 日
編集済み: Mohammad Sami 2020 年 1 月 26 日
No. I am suggesting that your UI update needs to be from inside the "other activity" code. If your other activity is primarily executing a for / while loop, you can also put in a line to update the UI.
If not, you can update the UI after completing certain appropriate "milestones" in your "other activity" code.
Mohammad Sami
Mohammad Sami 2020 年 1 月 26 日
Also another option to show "activity" in appdesigner is to use uiprogressdlg. This will show a progress bar, which you can use to show the milestones / progress on.
progrssbar = uiprogressdlg(app.UIFigure);
progrssbar.Value = 0.1;
progrssbar.Message = 'Doing A';
% activity A
progrssbar.Value = 0.5;
progrssbar.Message = 'Doing B';
% activity B
progrssbar.Value = 1;
progrssbar.Message = 'Finished';
close(progrssbar);

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by