Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
GUI axes slowdown

Subject: GUI axes slowdown

From: Daphne

Date: 9 Jan, 2008 19:58:02

Message: 1 of 3


I have a complex GUI that does a repetative task on an
image every time the user presses a pushbutton (supposedly
after they have changed a parameter). Then the gui calls
to axes in it and replots the image and whatever changes
were made.
What I have noticed is that every time I do this, there is
a slowdoen in the time it takes to do the same calculation
(even with the same parameters) this starts at 1.8 sec -->
grows to infinity (?).

Using the profiler I saw that the functions that pop up as
the trouble makers are
- axes(handles.axes3);
- linkaxes(ax);

Any idea how to stop this slowdown from happening?
I've tried to clear axes and ax... but (of course) didn't
help.

Thanks,
Daphne

Subject: GUI axes slowdown

From: matt dash

Date: 9 Jan, 2008 23:34:02

Message: 2 of 3

I'm not sure about linkaxes, but I've also noticed that the
axes command is extremely slow in gui's containing multiple
axes. I've never noticed it getting slower each time though
(but I wouldn't rule it out.) Maybe this is because you are
actually creating new axes each time without reusing the old
ones?

Luckily, there are very few (if any) cases where you have to
use the axes command. Instead of using axes() to make an
axes current, just specify it as the parent directly in your
plotting commands. most plotting commands can take the
target axes as the first argument, or using the 'parent'
property. (Note there are a few exceptions, like if you're
using mapping toolbox commands) I usually find this is
helpful anyway since it makes it easier to keep track of
exactly where your plots are going.

examples:
plot(handles.axes3,x,y)
line(x,y,'parent',handles.axes3)

Or if you're changing a plot that already exists, always
refer to it directly by its handle instead of relying on gca.

Subject: GUI axes slowdown

From: Stephane Carlier

Date: 10 Jan, 2008 16:22:02

Message: 3 of 3

First make sure you don't have any "hold on" that holds
older objects (even they may be not visible).

Then when you plotting, don't try to re-create new object,
instead, using set function. For example, suppose you
need to replot the image in one of the axes.
At the first iteration:
handles.hImage = image(X1);
At the second iteration, only update the image 'CData'
property instead of re-drawing it.
set(handles.hImage, 'CData', X2)

Use this technique for all other graphic objects such
as line, etc. Notice you can set "Visible" properties
if you don't want to show a particular graphic object.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us