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:
Speed of Execution of set(hFig,'UserData',ud)

Subject: Speed of Execution of set(hFig,'UserData',ud)

From: Rick O'Donnell

Date: 22 Jul, 2002 10:38:45

Message: 1 of 5

Hi,


I am inquiring to see if anyone has any guidelines as to what
influences the speed at which a 'UserData' structure can be stored
back into a figure handle. I have a 'UserData' structure 'ud'
containing up to 50-60 MB of data or more, plus arrays of other
handles of axes, pushbuttons, and text fields, all of which are
children of the parent figure.


I have a mouse motion function that will detect whether the mouse
pointer is over the axis or over the surrounding border. If it is
over the axis, it calls a subfunction to change the mouse pointer to
a 'crosshair'. If it is over the surrounding border, it calls the
same subfunction to change the mouse pointer to an 'arrow'. Another
subfunction is then called to see if the mouse pointer is over a
channel label text field. If it is, the code makes visible an
additional text field containing an expanded description of that data
channel.


All of these operations involve changes to the attributes of certain
handles, ud.hdls. ... The changes are updated in the figure using
set(hFig,'UserData',ud);


I have a 450 MHz Pentium III with Linux 7.2 and Matlab 5.3 and 6.1 as
a development platform. Depending on what data I'm displaying, I
have seen the set(hFig,'UserData',ud) command take as long as 440 ms
or as little as 1.4 ms (using tic, toc). If it takes 440 ms, then
it slows down the mouse response very noticeably.


Any one tried anything like this?


Thanks,


Rick O'Donnell

Subject: Speed of Execution of set(hFig,'UserData',ud)

From: lummert

Date: 22 Jul, 2002 16:57:38

Message: 2 of 5

Rick,

you can use persistent variables in your
'mouse move'-function.
They may contain your UserData object or
just some states you change on every execution.
Cheers,

      robert

Subject: Speed of Execution of set(hFig,'UserData',ud)

From: Rick O'Donnell

Date: 6 Aug, 2002 09:03:45

Message: 3 of 5

This is a response to Robert Lummert's suggestion:


Could you explain what you meant by 'persistent variables'? Could
you explain what you meant by persistent variables containing my
'UserData' object?


Thanks.


I further note, based on my original letter, that my executions of
set(hFig,'UserData',ud) were taking much longer for certain smaller
datasets making up the 'ud' structure than for larger datasets. This
seems paradoxical.


>
> you can use persistent variables in your
> 'mouse move'-function.
> They may contain your UserData object or
> just some states you change on every execution.
> Cheers,
>
> robert
>
>

Subject: Speed of Execution of set(hFig,'UserData',ud)

From: Cris Luengo

Date: 8 Aug, 2002 11:46:04

Message: 4 of 5

I've noticed too that, for some structures, especially with large data
in them, updating the 'UserData' can be really slow. Up to seconds.

I also noticed that first setting the 'UserData' to [] and then to the
new structure solves this. I don't know if it is a feature or a bug,
but I've been doing it like this ever since:

  udata = get(h,'UserData');
  udata.n = udata.n+1;
  set(h,'UserData',[])
  set(h,'UserData',udata)

Cris.

Rick O'Donnell wrote:
> Hi,
>
>
> I am inquiring to see if anyone has any guidelines as to what
> influences the speed at which a 'UserData' structure can be stored
> back into a figure handle. I have a 'UserData' structure 'ud'
> containing up to 50-60 MB of data or more, plus arrays of other
> handles of axes, pushbuttons, and text fields, all of which are
> children of the parent figure.
>
>
> I have a mouse motion function that will detect whether the mouse
> pointer is over the axis or over the surrounding border. If it is
> over the axis, it calls a subfunction to change the mouse pointer to
> a 'crosshair'. If it is over the surrounding border, it calls the
> same subfunction to change the mouse pointer to an 'arrow'. Another
> subfunction is then called to see if the mouse pointer is over a
> channel label text field. If it is, the code makes visible an
> additional text field containing an expanded description of that data
> channel.
>
>
> All of these operations involve changes to the attributes of certain
> handles, ud.hdls. ... The changes are updated in the figure using
> set(hFig,'UserData',ud);
>
>
> I have a 450 MHz Pentium III with Linux 7.2 and Matlab 5.3 and 6.1 as
> a development platform. Depending on what data I'm displaying, I
> have seen the set(hFig,'UserData',ud) command take as long as 440 ms
> or as little as 1.4 ms (using tic, toc). If it takes 440 ms, then
> it slows down the mouse response very noticeably.
>
>
> Any one tried anything like this?
>
>
> Thanks,
>
>
> Rick O'Donnell

Subject: Speed of Execution of set(hFig,'UserData',ud)

From: Ray

Date: 6 May, 2011 19:22:04

Message: 5 of 5

I'm sorry to reply to such an old thread, but I was struggling with this myself using a modern version of MATLAB. The problem still occurs, and it slows my GUI down mightily.

Using your solution of sending an empty matrix to UserData made my response go from over 2 seconds in profiler to 0.002 seconds! Amazing!

Thanks!

Cris Luengo <cris@ph.tn.tudelft.nl> wrote in message <3D523DDC.9070806@ph.tn.tudelft.nl>...
> I've noticed too that, for some structures, especially with large data
> in them, updating the 'UserData' can be really slow. Up to seconds.
>
> I also noticed that first setting the 'UserData' to [] and then to the
> new structure solves this. I don't know if it is a feature or a bug,
> but I've been doing it like this ever since:
>
> udata = get(h,'UserData');
> udata.n = udata.n+1;
> set(h,'UserData',[])
> set(h,'UserData',udata)
>
> Cris.
>
> Rick O'Donnell wrote:
> > Hi,
> >
> >
> > I am inquiring to see if anyone has any guidelines as to what
> > influences the speed at which a 'UserData' structure can be stored
> > back into a figure handle. I have a 'UserData' structure 'ud'
> > containing up to 50-60 MB of data or more, plus arrays of other
> > handles of axes, pushbuttons, and text fields, all of which are
> > children of the parent figure.
> >
> >
> > I have a mouse motion function that will detect whether the mouse
> > pointer is over the axis or over the surrounding border. If it is
> > over the axis, it calls a subfunction to change the mouse pointer to
> > a 'crosshair'. If it is over the surrounding border, it calls the
> > same subfunction to change the mouse pointer to an 'arrow'. Another
> > subfunction is then called to see if the mouse pointer is over a
> > channel label text field. If it is, the code makes visible an
> > additional text field containing an expanded description of that data
> > channel.
> >
> >
> > All of these operations involve changes to the attributes of certain
> > handles, ud.hdls. ... The changes are updated in the figure using
> > set(hFig,'UserData',ud);
> >
> >
> > I have a 450 MHz Pentium III with Linux 7.2 and Matlab 5.3 and 6.1 as
> > a development platform. Depending on what data I'm displaying, I
> > have seen the set(hFig,'UserData',ud) command take as long as 440 ms
> > or as little as 1.4 ms (using tic, toc). If it takes 440 ms, then
> > it slows down the mouse response very noticeably.
> >
> >
> > Any one tried anything like this?
> >
> >
> > Thanks,
> >
> >
> > Rick O'Donnell
>
>

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