diff --git a/SFS_HRTF_extrapolation/extrapolate_farfield_hrtfset.m b/SFS_HRTF_extrapolation/extrapolate_farfield_hrtfset.m index 37494482..68bdb1ce 100644 --- a/SFS_HRTF_extrapolation/extrapolate_farfield_hrtfset.m +++ b/SFS_HRTF_extrapolation/extrapolate_farfield_hrtfset.m @@ -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)); diff --git a/SFS_helper/progress_bar.m b/SFS_helper/progress_bar.m index a0344ef0..7a15dab3 100644 --- a/SFS_helper/progress_bar.m +++ b/SFS_helper/progress_bar.m @@ -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