Skip to content

Commit

Permalink
Another try on the progress_bar() function
Browse files Browse the repository at this point in the history
Now I included a [...    ] 30% variant
  • Loading branch information
hagenw committed Jul 9, 2013
1 parent 9a9bcc4 commit 5a13f90
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion SFS_HRTF_extrapolation/extrapolate_farfield_hrtfset.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
for ii = 1:nls

% show progress
%progress_bar(ii,nls);
progress_bar(ii,nls);

% direction of plane wave
[xs(1),xs(2),xs(3)] = sph2cart(phi(ii),theta(ii),R(ii));
Expand Down
28 changes: 26 additions & 2 deletions SFS_helper/progress_bar.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,35 @@ function progress_bar(ii,nii)
%% ===== Generate the progress bar =======================================
% \r is not working under some Windows systems, therefore we use \b to clear the
% line
str = sprintf('Run %.0f/%.0f',ii,nii);
% calculate percentage
perc = ii/nii * 100;
% get bar
if perc<10
bar = '[. ]';
elseif perc<20
bar = '[.. ]';
elseif perc<30
bar = '[... ]';
elseif perc<40
bar = '[.... ]';
elseif perc<50
bar = '[..... ]';
elseif perc<60
bar = '[...... ]';
elseif perc<70
bar = '[....... ]';
elseif perc<80
bar = '[........ ]';
elseif perc<90
bar = '[......... ]';
else
bar = '[..........]';
end
str = sprintf('Progress: %s %3.0f%%%%',bar,perc);
if ii==1
fprintf(1,str);
else
clear_line(length(str));
clear_line(length(str)-1);
fprintf(1,str);
end
if ii==nii
Expand Down

0 comments on commit 5a13f90

Please sign in to comment.