Print in script outputs figures before all lines above it done, and other issues

1 view (last 30 days)
With print, can I force a "wait until catchup" in a script? It seems presently my script is printing deformed figures. They show fine as figures after the script execution is over, and print fine then. But the script that is supposed to output several images occasionally produces crap. Crap has been:
Parts missing from the figure
Priting parts of a wrong figure to a given file
Not getting aspects right (axis versus font sizes)
I generally use set(gcf,'WindowState','maximized') to set a consistent figure size in script, and output with print('-dpng',..)
If it matters, I am working from a network drive location, with two computers running two independent matlabs "homed" to the same folder. (Both computers operate from the same screen, in case that matters for aspects)

Accepted Answer

Nick
Nick on 14 Nov 2018
A typical problem in GUI's with images or plots in an axes not updating can often be solved by adding a drawnow after the moment it should update. In your case my guess would be right before each print. In pseudo code it would look something like this in pseudo code:
  1. perform processing
  2. set figure
  3. drawnow
  4. print
I could misinterpred your question or it could be a different problem, hard to tell without sample code. If this does not solve the problem provide some sample code and example data.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!