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'开发者_JAVA技巧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?
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.
精彩评论