for k = ...
try
your code here
catch
fprintf('loop number %d failed\n',k)
end
end
ref : How do I skip an error in a loop? - MATLAB Answers - MATLAB Central (mathworks.cn)
%%% use parallel compute
% f = waitbar(0, 'Starting');
n = length(file_list);
parpool(10); % 确定使用的核心数量
% Then construct a ParforProgressbar object:
ppb = ParforProgressbar(n);
parfor i = 1:n
try
%%% input your code
catch
fprintf('loop number %d failed\n',k)
end
% waitbar(i/n, f, sprintf('Progress: %d %%', floor(i/n*100)));
ppb.increment();
end
delete(ppb); % 删除进度条
delete(gcp('nocreate')) %关闭当前并行池
ref: PARFOR progress monitor (progress bar) v4 - File Exchange - MATLAB Central (mathworks.cn)
注意该脚本无法在matlab 的交互式脚本内运行
解决办法见上面网页里面的评论区:
a very simple fix is to add "'Visible', 'on'" to the figure options when creating the figure (line 196 "progressbar.m").