Prints the time to completion and expected finish of a looped simulation based on linear extrapolation. Syntax: [ num_curr_char ] = showTimeToCompletion( percent_complete, num_prev_char ) Note that before using this function in a loop the in-built MATLAB function tic should be called. Inputs: percent_complete - A decimal number between 0 and 1 representing the percentage completion. num_prev_char - Number of previous characters printed to the screen (Usually ok to begin with 0 and then reuse num_curr_char) Outputs: num_curr_char - Number of characters printed to the screen. Usually feed this number back into this function on the next iteration or increment appropriately if other characters have been printed between function calls. Example: % Example 1 fprintf('\t Completion: '); n=0; tic; len=1e2; for i = 1:len pause(1); n = showTimeToCompletion( i/len, n); end % Example 2 fprintf('\t Completion: '); showTimeToCompletion; tic; len=1e2; for i = 1:len pause(1); showTimeToCompletion( i/len ); end % Example 3 fprintf('\t Completion: '); showTimeToCompletion; startTime=tic; len=1e2; p = parfor_progress( len ); parfor i = 1:len pause(1); p = parfor_progress; showTimeToCompletion( p/100, [], [], startTime ); end See also: tic, toc, parfor_progress