×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Slider callback plot flicker problem...

Slider callback plot flicker problem...

Slider callback plot flicker problem...

(OP)
Hey hey hey!

Whenever I want to analyze a mathematical function with multiple parameters I make a quick GUI in Matlab. I assign sliders to each of the parameters I want to change and their callback functions replot the function with the new value. Here is a very simple example:


Main Program
-------------------------------------------------------
a=4;
fighandle=figure(1)
slidehandle = uicontrol(fighandle,'Style','Slider')
set (slidehandle,'Value',4,'Min',1,'Max',20,'Callback','UIcall_2(slidehandle)')
set (slidehandle,'SliderStep',[0.1 1])
x=1:100;
y=x.^2+a.*x;
plot(x,y,'x')
----------------------------------------------------------



Callback Function
----------------------------------------------------------
function UIcall(slidehandle)
a=get(slidehandle,'Value')
x=1:100;
y=x.^2+a.*x;
plot(x,y,'x')
----------------------------------------------------------


Nice isn't it?
Well, this is my problem:
When I klick and hold on one of the slider arrows to make it sweep through it's range the whole figure flickers!
Sure you can see the curve changing shape and all that but my current project includes a bunch of lines and A LOT of sweeping sliders through their ranges, full screen of course, and this flickering is a big problem!
I'm not epileptic but if I was I would have seized for good by now!

Just a few minutes ago after I had been messing with it the damned thing started to move smooth as silk without a trace of flickering! Just the lines changing supersmooth on the screen but ofcourse next time I hit run it was back to hysteric flickering...

What's causing this and how can I make it go away?

Is it a figure property issue, NextPlot or something?

Or should I plot using line instead?

Or perhaps plot using set(line_handle,'XData',x,'YData',y)?

Thank you for reading this far and good night!



RE: Slider callback plot flicker problem...

(OP)
Well since nobody had the opportunity to answer me I just have to do it myself...

Hey Jacc

Very good question! It has a very simple solution. Set the figure property 'DoubleBuffer' to 'on'. I found this on another Matlab forum.

Although your own suggestions won't help the flicker it will certainly speed things up. I did a simple for loop with different plot methods in it and timed the loop with tic toc.

 The plot command calls another 45 lbs of m-files before it's done, amazing that it doesn't take longer. I found out by using the debug function 'step-into'.

The line command is about a hundred times faster.

Using set(line_handle,'XData',x,'YData',y) is super duper fast! Something like 10 000 times faster than using plot! You might have to use the drawnow command, though.

Here is the link to the other forum:

http://groups.google.se/group/comp.soft-sys.matlab/browse_frm/thread/4f7e8c047c2f8ef3/68fd3d7d0976e3b9?lnk=st&q=plot+flicker+sbotlite&rnum=1&hl=sv#68fd3d7d0976e3b9

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources