function statusdots(p,total,num) <p> is the index (starting from 1) <total> is the total number of things to process <num> (optional) is the desired number of dots. default: 20. depending on the value of <p>, fprintf out an '.' such that we write out a total of <num> dots, equally spaced as best as possible. we start with a dot when <p> is 1. example: fprintf('starting'); for p=1:57 statusdots(p,57,10); pause(.1); end fprintf('done.\n');
0001 function statusdots(p,total,num) 0002 0003 % function statusdots(p,total,num) 0004 % 0005 % <p> is the index (starting from 1) 0006 % <total> is the total number of things to process 0007 % <num> (optional) is the desired number of dots. default: 20. 0008 % 0009 % depending on the value of <p>, fprintf out an '.' 0010 % such that we write out a total of <num> dots, 0011 % equally spaced as best as possible. we start 0012 % with a dot when <p> is 1. 0013 % 0014 % example: 0015 % fprintf('starting'); 0016 % for p=1:57 0017 % statusdots(p,57,10); 0018 % pause(.1); 0019 % end 0020 % fprintf('done.\n'); 0021 0022 % input 0023 if ~exist('num','var') || isempty(num) 0024 num = 20; 0025 end 0026 0027 % do it 0028 points = round(linspacecircular(1,total+1,num)); 0029 if ismember(p,points) 0030 fprintf('.'); 0031 end