i want to add a waitbar

2 次查看(过去 30 天)
hi i want to add a waitbar to my program,which displays the folder name of each iteration
HERE'S MY CODE
parentDir={'C:\Users\HP\Documents\Matlab\FOLDER AA',
'C:\Users\HP\Documents\Matlab\FOLDER BB',
'C:\Users\HP\Documents\Matlab\FOLDER CC',
'C:\Users\HP\Documents\Matlab\FOLDER DD',
'C:\Users\HP\Documents\Matlab\FOLDER EE',
'C:\Users\HP\Documents\Matlab\FOLDER FF',
'C:\Users\HP\Documents\Matlab\FOLDER GG',
'C:\Users\HP\Documents\Matlab\FOLDER HH',
'C:\Users\HP\Documents\Matlab\FOLDER II',
'C:\Users\HP\Documents\Matlab\FOLDER KK',
'C:\Users\HP\Documents\Matlab\FOLDER LL',
'C:\Users\HP\Documents\Matlab\FOLDER MM',
'C:\Users\HP\Documents\Matlab\FOLDER NN',
'C:\Users\HP\Documents\Matlab\FOLDER OO',
'C:\Users\HP\Documents\Matlab\FOLDER PP',
'C:\Users\HP\Documents\Matlab\FOLDER QQ',
'C:\Users\HP\Documents\Matlab\FOLDER RR',
'C:\Users\HP\Documents\Matlab\FOLDER SS',
'C:\Users\HP\Documents\Matlab\FOLDER TT',
'C:\Users\HP\Documents\Matlab\FOLDER UU'}
for j = 1:length(parentDir);
matchList{j} = [matchList{j}; names(endIdx == strLen & endIdx > 0)'];
end

采纳的回答

Kojiro Saito
Kojiro Saito 2019-2-25
This example (in R2014a) might be useful and here is a sample code. You need to create waitbar before for loop and update inside the loop.
% Create initial waitbar
f = waitbar(0, '', 'CreateCancelBtn','setappdata(gcbf,''canceling'',1)');
for j = 1:length(parentDir)
matchList{j} = [matchList{j}; names(endIdx == strLen & endIdx > 0)'];
% In order to avoid "invalid interpreter syntax" warning
folderNameWithValid = strrep(parentDir{j}, "\", "\\");
% Update waitbar and message
waitbar(j/length(parentDir), f, sprintf('Reading %s', folderNameWithValid))
end
% Delete waitbar
delete(f)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

标签

产品


版本

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by