📄 workbar.m
字号:
% Enforce a minimum time interval between updates
if etime(clock,lastupdate) < 0.01
return
end
% Update progress patch
n = [.02857 ];
set(progpatch,'XData',[1 n(1)*round(fractiondone/n(1)) n(1)*round(fractiondone/n(1)) 1])
% Set all dynamic text
runtime = etime(clock,starttime);
if ~fractiondone,
fractiondone = 0.001;
end
work = get(progfig,'userdata');
try progtitle;
catch
progtitle = work.progtitle;
end
try message;
catch
message = work.message;
end
timeleft = runtime/fractiondone - runtime;
timeleftstr = sec2timestr(timeleft);
titlebarstr = sprintf('%2d%% %s',percentdone,progtitle);
set(progfig,'Name',titlebarstr)
set(text(1),'string',message);
set(text(3),'string',[timeleftstr ' minutes']);
set(text(4),'string',[num2str(percentdone) ' %']);
% Force redraw to show changes
drawnow
% Record time of this update
lastupdate = clock;
% ------------------------------------------------------------------------------
function timestr = sec2timestr(sec)
% Convert seconds to hh:mm:ss
% h = floor(sec/3600); % Hours
% sec = sec - h*3600;
m = floor(sec/60); % Minutes
sec = sec - m*60;
s = floor(sec); % Seconds
if isnan(sec),
% h = 0;
m = 0;
s = 0;
end
% if h < 10; h0 = '0'; else h0 = '';end % Put leading zero on hours if < 10
if m < 10; m0 = '0'; else m0 = '';end % Put leading zero on minutes if < 10
if s < 10; s0 = '0'; else s0 = '';end % Put leading zero on seconds if < 10
% timestr = strcat(h0,num2str(h),':',m0,...
% num2str(m),':',s0,num2str(s));
timestr = strcat(m0,...
num2str(m),':',s0,num2str(s));
function a=progimage(m),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -