statusdots.m 683 B

12345678910111213141516171819202122232425262728293031
  1. function statusdots(p,total,num)
  2. % function statusdots(p,total,num)
  3. %
  4. % <p> is the index (starting from 1)
  5. % <total> is the total number of things to process
  6. % <num> (optional) is the desired number of dots. default: 20.
  7. %
  8. % depending on the value of <p>, fprintf out an '.'
  9. % such that we write out a total of <num> dots,
  10. % equally spaced as best as possible. we start
  11. % with a dot when <p> is 1.
  12. %
  13. % example:
  14. % fprintf('starting');
  15. % for p=1:57
  16. % statusdots(p,57,10);
  17. % pause(.1);
  18. % end
  19. % fprintf('done.\n');
  20. % input
  21. if ~exist('num','var') || isempty(num)
  22. num = 20;
  23. end
  24. % do it
  25. points = round(linspacecircular(1,total+1,num));
  26. if ismember(p,points)
  27. fprintf('.');
  28. end