Borrar filtros
Borrar filtros

How to speed up GUI

8 visualizaciones (últimos 30 días)
Giovanni
Giovanni el 7 de Sept. de 2011
Hi people,
I have another question:
My gui has 4 axes elements, and an uitable. Now I am basically able to get the row index number and to use it in such a way I can put a marker (colored line) on the four plots contemporarily. The problem is now the speed. It takes very long to redraw all the four figures and the four lines eveytime i choose another element. how could I menage this?
I have a launch button, which during its own callback is reading an excel file, processing the data someway and generating the four vectors to plot. After that a refresh function is called, which plots the data in the right format, and puts the marker into a starting position. After that I call the refresh function evey time I choose a new value from the table, and this redraws the whole 4 graphics and the markers.
Which could be a better way to obtain this behaviour in less time?

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Sept. de 2011
When practical, use set() to update existing graphics rather than creating new graphics.
If you are updating several graphic items, it is often faster to set() the figure or axes visibility to off, do the updates, and then set it to be visible again.
Avoid using figure() or axes() to make a particular figure or axes the "current" one. Instead, explicitly parent operations. For example, instead of
axes(handles.axes1);
plot(x, y)
use
plot(handles.axes1, x, y);
or
plot(x, y, 'Parent', handles.axes1);
and instead of
figure(handles.guifig)
you can use
set(0, 'CurrentFigure', handles.guifig);
The figure() and axes() calls raise the object and make it visible, triggering a graphics update: you are trying to delay all graphics updates until you everything is in its place.
If you do need to call axes(), triggering a graphics update you do not want yet, then immediately (e.g., next statement) set() the visibility of the axes to be off. If you get the set() in early enough, then at least on Linux the window will not even "flash".

Más respuestas (1)

Titus Edelhofer
Titus Edelhofer el 7 de Sept. de 2011
Usually you can speed up significantly by avoiding to redraw everything. When you plot the first time, save the handle:
handles.plot1 = plot(handles.axes1, ...);
guidata(hObject, handles);
When your callback wants to redraw, don't redraw everything but do something like
newX = ...;
newY = ...;
set(handles.plot1, 'xdata', newX, 'ydata', newY);
Titus

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by