📄 workbar.m
字号:
% Access progfig to see if it exists ('try' will fail if it doesn't)
dummy = get(progfig,'UserData');
% If progress bar needs to be reset, close figure and set handle to empty
if fractiondone == 0
delete(progfig) % Close progress bar
progfig = []; % Set to empty so a new progress bar is created
end
catch
progfig = []; % Set to empty so a new progress bar is created
end
if nargin < 2 & isempty(progfig),
message = '';
end
if nargin < 3 & isempty(progfig),
progtitle = '';
end
% If task completed, close figure and clear vars, then exit
percentdone = floor(100*fractiondone);
if percentdone == 100 % Task completed
delete(progfig) % Close progress bar
clear progfig progpatch starttime lastupdate % Clear persistent vars
return
end
% Create new progress bar if needed
if isempty(progfig)
%%%%%%%%%% SET WINDOW SIZE AND POSITION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
winwidth = 300; % Width of timebar window
winheight = 75; % Height of timebar window
screensize = get(0,'screensize'); % User's screen size [1 1 width height]
screenwidth = screensize(3); % User's screen width
screenheight = screensize(4); % User's screen height
winpos = [0.73*(screenwidth-winwidth), ...
0.3*(screenheight-winheight),...
winwidth, winheight]; % Position of timebar window origin. Default: .73, .3
wincolor = [0.878,0.875,0.89]; % Default window color similar to GUI
% [ 0.9254901960784314,...
% 0.9137254901960784,...
% 0.8470588235294118 ]; % Alternative window color
est_text = 'Estimated time remaining: '; % Set static estimated time text
pgx = [0 0];
pgy = [41 43];
pgw = [57 57];
pgh = [0 -3];
m = 1;
%%%%%%%% END SET WINDOW SIZE AND POSITION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Initialize progress bar
progfig = figure('menubar','none',... % Turn figure menu display off
'numbertitle','off',... % Turn figure numbering off
'position',winpos,... % Set the position of the figure as above
'color',wincolor,... % Set the figure color
'resize','off',... % Turn of figure resizing
'tag','timebar'); % Tag the figure for later checking
work.progtitle = progtitle; % Store initial values for title
work.message = message; % Store initial value for message
set(progfig,'userdata',work); % Save text in figure's userdata
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -