displayProgress.m 392 B

123456789101112131415
  1. function displayProgress(msg,iter,total)
  2. % display message for updating progress
  3. % setup for first iteration
  4. if(iter == 1)
  5. fprintf(1,[msg ' ']); % an extra space takes care of the first backspace
  6. end
  7. % update through the iterations
  8. fprintf(1,[repmat('\b',1,numel(num2str(iter-1))) '%d'],iter);
  9. % a new line for the end of the loop
  10. if(iter == total)
  11. fprintf('\n');
  12. end