필터 지우기
필터 지우기

How to speed up GUI

조회 수: 8 (최근 30일)
Giovanni
Giovanni 2011년 9월 7일
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?

채택된 답변

Walter Roberson
Walter Roberson 2011년 9월 7일
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".

추가 답변 (1개)

Titus Edelhofer
Titus Edelhofer 2011년 9월 7일
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

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by