i want to add a waitbar

3 views (last 30 days)
Ishak Oussama
Ishak Oussama on 20 Feb 2019
Answered: Kojiro Saito on 25 Feb 2019
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

Accepted Answer

Kojiro Saito
Kojiro Saito on 25 Feb 2019
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)

More Answers (0)

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Tags

Products


Release

R2014a

Community Treasure Hunt

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

Start Hunting!