フィルターのクリア

Listen for task progress on matlab

19 ビュー (過去 30 日間)
Lola
Lola 2022 年 6 月 15 日
編集済み: ILoveMATLAB 2022 年 6 月 16 日
Hello. I want to know the progress when I execute matlab code. I am reading numeric data from a csv file, plotting this data, and then writing the data to a excel sheet. I want to add a progress bar for each of these tasks on GUI created in app designer because there is a lag time when reading and writing executed so I do not know when the task is complete. I am not sure how to do this. Below is the code i have thus far. Please assist.
Data=readtable('data.csv',NumHeaderLines',10);
col_vec=data{:2}; plot(app.UIAxes,col_vec);
xlswrite('Data.xls',col_vec,sheet,'HR','Range','A1');
app.ProgressBar.startProgress("The task is starting...");
pause(5)
app.ProgressBar.setProgress(0.20),"The task is running...");
app.ProgressBar.finishProgress("The task is finished");

回答 (1 件)

ILoveMATLAB
ILoveMATLAB 2022 年 6 月 16 日
If you have an app you can just use uiprogressdlg.
function myprogress1
fig = uifigure;
d = uiprogressdlg(fig,'Title','Please Wait',...
'Message','Opening the application');
pause(.5)
% Perform calculations
% ...
d.Value = .33;
d.Message = 'Loading your data';
pause(1)
% Perform calculations
% ...
d.Value = .67;
d.Message = 'Processing the data';
pause(1)
% Finish calculations
% ...
d.Value = 1;
d.Message = 'Finishing';
pause(1)
% Close dialog box
close(d)
end
  2 件のコメント
Lola
Lola 2022 年 6 月 16 日
The values .33 and .67 Can you please explain to me what they mean ? Is matlab able to display the text after the calculation is completed because I do not know how long it should take for matlab to perform a certain task
ILoveMATLAB
ILoveMATLAB 2022 年 6 月 16 日
編集済み: ILoveMATLAB 2022 年 6 月 16 日
It would easier for you to understand if you ran the code. Nevertheless, value is the percent complete that you want to display. 0.33 means the progess bar will be 33% long. The message is the progess bar message.
Yes, the example shows that you can continue to update the progress bar after a calculation. The pause function is just a placeholder. You can replace the pause function with your calculation.
Please run and step through the example.

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

カテゴリ

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