GUI slows down when plotting to figure sequentially
10 次查看(过去 30 天)
显示 更早的评论
I built a MATLAB GUI that displays images in 9 figures. It also displays one graphical x vs y plot in another figure in the GUI. The images and data for the plot are read all at once but displayed sequentially. We have thousands of images to display. When the GUI runs showing the images (using the imagesc command) only (commenting out the plotting x vs y section), it runs at an acceptable, steady speed. But when I run the GUI updating and plotting (using the plot command) the x vs y plot figure, it starts at an OK speed but quickly slows down to a crawl. For the x vs y plot, I’m using a code similar to the one provided as an answer here: https://www.mathworks.com/matlabcentral/answers/217077-matlab-gui-updating-plot. I'm using the hold 'on' command because I want to see the history of the plot.
Is there a way to speed up this plotting to GUI?
UPDATE (Oct 31, 2017): I noticed that when I replaced the "hold(handles.window,'on')" and "hold(handles.window,'off')" by generic "hold on" and "hold off," it eliminated the gradual slow down of the display. Now it displays the images at a constant rate (with no slow down).
1 个评论
Adam
2017-10-26
What are you actually plotting in your x vs y plot? You should be plotting it all as a single graphics object that you update. If you are plotting a new graphics object for every point then it will slow down a lot because graphics objects are expensive and even if they don't look any more on screen 100 graphics objects instead of 1 giving the same data take a lot more memory and slow your execution down a lot. 1000 even more so, etc, etc.
回答(2 个)
Rik
2017-10-26
With hold on your plot is containing more data every loop, which slows down your function. A solution is to not use hold on, but (using handles) only keeping the last few plots in your figure.
Yair Altman
2017-10-26
编辑:Yair Altman
2017-10-26
You might find the tips mentioned in the following articles useful - many of them deal directly with graphics performance:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!