generating animation (e.x. animated gif) while function is running

3 views (last 30 days)
Hi at all,
I have programmed a tool that analyzes measured data, performs several calculations and generates an excel report at the end. Some of its functions or better calculations take a bit of time for their execution, so I want to generate a small animation on the Main-GUI to show the user that the tool is still running.
My idea is to put an animated gif on the GUI while the functions are running and to replace it by an still image when the tool is on idle.
Is this possible somehow? Or, if not is there an other way to achieve this idea?
Thanks for your help.
Greetings, Stefan

Accepted Answer

Jan
Jan on 24 Aug 2011
You cannot display an animated GIF with standard MATLAB methods.
Usually a progressbar is displayed for such jobs. Beside MATLAB's WAITBAR, there are a surprising large number of submissions in the Fex: progressbar? .
If your code contains a loop, you can update an image after a certain time step. Or you can create a timer object, which updates an image object. A DRAWNOW might be needed to allow the timer's callback to be executed.
If you call a single command, which takes a lot of time (e.g. invert a giantic matrix), I do not know a sufficient method, because MATLAB is a single threaded application (even if it calls multi-threaded subfunctions) and the main thread cannot be interrupted. It should be possible to start an independent external function, which updates an animation, but this will niot appear inside the MATLAB figure.

More Answers (1)

Stefan
Stefan on 29 Aug 2011
Hello Jan,
thanks for your answer. So I will kick this animation out of my GUI.
Greetings,
Stefan

Categories

Find more on Animation in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!