How to improve performance of GUIs ?

7 views (last 30 days)
Hello all , Its a general but crucial question . I want to ask that what are the factors which work on GUI performance and smoothness ? I want to develop a complicated and multi functional GUI , about what factors I should take care ? Thank you .
  4 Comments
yogesh jain
yogesh jain on 10 Jan 2016
High Level Graphics , Mr. Roberson .
Walter Roberson
Walter Roberson on 11 Jan 2016
Edited: Walter Roberson on 11 Jan 2016
Every version of MATLAB that has supported graphics has supported "high level graphics", so the minimum configuration of your system would probably be something like MATLAB 2 on an Intel 286-class system with an early version of MS Windows. If you could still find such a system in working order. But the earliest release of MATLAB that you can still obtain is MATLAB 5, if you can find a copy of the book that was published that offered MATLAB on CDROM. If you cannot find that book, then the earliest MATLAB that you can still obtain from Mathworks is around MATLAB R13, so you will need at least 16 megabytes of RAM
If you meant to ask about the minimum configuration for the current release then see http://www.mathworks.com/support/sysreq/current_release/

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Jan 2016
Beyond that: if you use a handles structure, avoid storing large data in it, as that data would get copied around a lot. If you have large data, you can use getappdata() which at least gives you one level of subdivision on what needs to be copied. Also using handle objects saves on data being copied.
Avoid using global: it is one of the very slowest ways of transferring data.
Update graphics objects instead of building new ones. For example, instead of calling plot() in a loop, obtain the handles to the lines and update their XDATA, YDATA (and ZDATA) properties.
Be sure your graphics objects are getting deleted after you use them. On the other hand, if you have a GUI that is only present sometimes, it is more efficient to build it once and set it invisible when you do not need it, rather than deleting it and recreating it.
If you are developing non-trivial GUI code, then I recommend that you get in the habit of explicitly defining the parent of every graphics object you create. In many cases you can do that by passing an axes handle in as the first argument of a graphics call, but in other cases you may need to pass a 'Parent' name/value pair. For example instead of
figure;
plot(1:10, rand(1,10))
hold on
plot(1:10, randn(1,10))
hold off
instead code
f = figure();
ax = axes('Parent', f);
plot(ax, 1:10, rand(1,10));
hold(ax, 'on');
plot(ax, 1:10, randn(1,10));
hold(ax, 'off')
This is not so much a performance issue as it is a matter of sanity: without it you are almost certain to find that at some point the axes or figure you think you are drawing on is not the active axes or figure. And if you do any debugging, you are pretty likely to accidentally make the wrong axes or figure the current one in the process of moving windows around so that you can see the console or the source code. It is a bit of a nuisance to code it in every call, but it really makes a big difference for your sanity.
And then there is the fact that if you code this way then you seldom need to make a figure or axes "current" (you do not need gcf or gca if you are being careful to store and pass the information around.) When you make a figure active then that is one of the defined triggers for processing the graphics queue and rendering everything, which is something you want to avoid doing for performance reasons. Postpone, postpone, postpone -- no point in drawing something that might be changed by something else before the first thing is actually needed.
  3 Comments
Stephen23
Stephen23 on 8 Jan 2016
Search this forum for alternatives to global. You will find lots of discussions on this topic. You might as well start with MATLAB's own documentation:
One of the most popular ways is to use guidata:
yogesh jain
yogesh jain on 9 Jan 2016
Thanks a lot Mr. Stephen , it was helpful

Sign in to comment.

More Answers (1)

Yair Altman
Yair Altman on 8 Jan 2016
I believe that you will find the following useful: http://undocumentedmatlab.com/blog/some-performance-tuning-tips
It specifically addresses the issue of Matlab GUI performance

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!