0

I am now programming a Matlab GUI for accessing current point of cursor on an axes whenever user changes the location of cursor. However, I found a strange phenomenon that the speed of windowButtonMotionFcn got slower with an increase in number of GUI object. Below is the result

https://i.stack.imgur.com/fwjCK.jpg

I set the properties of all GUI objects as default value and my operating Matlab version is Matlab 2012a. Is there any possible way to keep the speed of windowButtonMotionFcn when number of GUI object increases?

Thank you for your attention and help. Myrick

Myrick Chow
  • 332
  • 1
  • 6
  • 16

3 Answers3

0

I do not know exactly how the event handlig is implemented in matlab. However, it seems reasonable that more gui objects will slow the process. Think of it as, more gui objects requires more memory, more objects to handle, more code, longer lists to search through... I have also experienced that the GUIs created with GUIDE is generally slower than a GUI made by hand. This is not tested in anyway and is thus not confirmed. However, when I do not need too many objects in the GUI, I normally prefer to create them by hand. The GUIDE guis is normally more general, but in most cases only a subset of the facilities is used anyway.

patrik
  • 4,506
  • 6
  • 24
  • 48
0

Try using the figure's underlying Java frame's MouseMovedCallback:

jFrame = get(handle(hFig), 'JavaFrame'); try % This works up to R2011a jClient = jFrame.fFigureClient; catch try % This works from R2008b and up, up to HG2 jClient = jFrame.fHG1Client; catch % This works in HG2 jClient = jFrame.fHG2Client; end end jWindow = handle(jClient.getWindow, 'CallbackProperties'); set(jWindow, 'MouseMovedCallback', @matlabCallbackFunction);

Yair Altman
  • 5,704
  • 31
  • 34
0

I had a bit similar problem with "slowing" and "memory leak".

Problem was avoided by using delete(gca) before redrawing only visible objects.

byquip
  • 1