GUIDE scrollfunction deleting figure
Show older comments
Hello, I have a question about my scrollfunction, I asked it here before but couldn't get a good response.
My question is this: I have a scrollfunction that works and works well. I have a gui I made in GUIDE with four axes, and the scrollfunction will change depending on the axes. My problem is this: depending on the rate at which I scroll, the figure can bug out and delete itself. After running some tics and tocs, I found the problem lies with how fast everything gets plotted.
When I scroll slower than it takes MATLAB to plot (~0.1/sec, meaning I can scroll upwards at 10 slices per second). When I scroll at a rate that would replot more than 10 times a second, it bugs out. THe reason I'm asking this, and just assuming its a MATLAB problem, is I have a separate duplicate programmatic GUI that does a identical process, with more or less the same code, that doesn't have this problem. I think the problem is within GUIDE.
Is this common, or is there a workaround? I tried to implement a pause of 0.1 seconds to try to get this bug to not occur, no dice. Regardless of what I do, whenever I try to scroll quickly, I have the figure deletion.
Thanks!
EDIT: Here are some segments of code from my UI. My scrolling function uses the mouse scroll wheel to go upwards and downwards in slices in a 3D matrix axially, sagittally and coronally by clicking on whatever GCA I want to sift through. My data consists of response data which I image in imagesc, and is again constructed in a 3D matrix. It represents a volume I export from a FEA utility.
I have attached the code to this question now as opposed to using gist.
These are the relevant graphics functions I employ at the moment. Besides that, here are some UI screenshots to help you get an idea of what my UI looks like:
And here is the error message I get when I scroll too quickly:
Error using drawnow
Error while evaluating DestroyedObject WindowScrollWheelFcn
Error using matlab.ui.Figure/set
Invalid or deleted object.
Let me know if you'd like me to upload anything else.
7 Comments
matt dash
on 10 Dec 2014
Hmm, i've never heard of this, so i'd say no it's not common. It might be a side effect of something specific in your code. You might try reading about the "busy action" and "interruptible" figure properties. Maybe you can use those to prevent it from calling the scroll function too often.
Geoff Hayes
on 11 Dec 2014
Brian - can you post a simple example of the code that is exhibiting this behaviour so that others can take a look?
Brian
on 11 Dec 2014
matt dash
on 11 Dec 2014
You would need to post the "display" functions too... those are likely where the error is happening since they do the actual clearing/redrawing.
Brian
on 12 Dec 2014
Geoff Hayes
on 12 Dec 2014
Edited: Geoff Hayes
on 12 Dec 2014
Brian - why not just attach your code using the paperclip button? When you attach only part of the code, it makes more challenging to determine where exactly the problem is..especially if we can't run it. That's why a sample GUI with some of your code that produces the same behaviour makes debugging (for others) that much easier.
Brian
on 14 Dec 2014
Accepted Answer
More Answers (1)
Image Analyst
on 11 Dec 2014
0 votes
Exactly what is getting scrolled? Do you have a slider/scrollbar and are changing it, which changes some parameter which then causes a plot/graph/chart/image to change? Or do you have a scrollpanel for an image and you're scrolling the image (like in attached demo)?
Well, whatever it is or however you're doing it, maybe try putting in a "drawnow" at a strategic place to force update of the display. You might also want to totally reset the axes with a "cla reset" in between separate scroll operations.
3 Comments
Brian
on 11 Dec 2014
Image Analyst
on 11 Dec 2014
Again, exactly what is being scrolled? A slider? An image? A panel? A screenshot would help immensely here.
Brian
on 12 Dec 2014
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!