Thursday, April 29, 2010

MATLAB progress bar, show the progress of computing

Sometimes during a lengthy procedure, we don't have good way to determine if the code is still running or the computer got stuck. Using a progress bar will let you know approximately how long you have to wait til the run is over. Very cool!

clc;
clear all;
tic;
disp ('Hello, World!');
h=waitbar(0,'Please wait..');
n=0;
for i=1:100
    waitbar(i/100)
    for j=1:100
        for k=0:100;
            n=factorial(2);
        end
    end
end
close(h)
toc

1 comment:

  1. Hi,

    I use 'dispstat' function just for this purpose. It can update the previous output which is a missing function of default 'disp'. Very simple to use. It can be downloaded from here: http://www.mathworks.com/matlabcentral/fileexchange/44673-overwritable-message-outputs-to-commandline-window

    ***Sample usage:
    dispstat('','init'); % One time only initialization
    dispstat(sprintf('Begining the process...'),'keepthis','timestamp');
    for i = 97:100
    dispstat(sprintf('Progress %d%%',i),'timestamp');
    %doing some heavy stuff here
    end
    dispstat('Finished.','keepprev');

    ***Output:
    11:25:37 Begining the process...
    11:25:37 Progress 100%
    Finished.

    All the best,

    ReplyDelete

Any comments?

my-alpine and docker-compose.yml

 ``` version: '1' services:     man:       build: .       image: my-alpine:latest   ```  Dockerfile: ``` FROM alpine:latest ENV PYTH...