views:

56

answers:

1

I am implementing an algorithm in MATLAB. Among other things it calculates the shortest paths etc. so it's quite demanding for my old computer. I've put in disp() calls through out the program to see what's happening all the time.

However when starting on a particulary heavy for loop the disp() seemes not to be called until the loop is over even though it comes before the loop. Why is that? I thought that MATLAB was really executing sequentially or am I just choking it with too many calculations and the disp() calls get the lowest priority?

+6  A: 

I am almost certain it is because of EDT.

That's the function drawnow() is for. See article of Yair Altman for good explanation.

Summary: MATLAB graphics is Java Swing and operations happen on a special thread - Event Dispatch Thread (EDT). Calling drawnow(); flushes event queue and updates figure window.

Mikhail
Seems to exactly the case. Putting in drawnow(); after the disp makes the function output the disp and then do the for loop it seems. Nice!
Reed Richards