i want to add a waitbar

조회 수: 3 (최근 30일)
Ishak Oussama
Ishak Oussama 2019년 2월 20일
답변: Kojiro Saito 2019년 2월 25일
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