Inconsistent handles structure in GUI callback function
Show older comments
I have a GUI which displays an image (it's a colormap, and each pixel contains signal data.) I want to be able to click a pixel and display a graph of the signal data that was stored in that pixel. That part works fine, the errors pop up when I try to select a second pixel. My intention is to create a subplot on a single figure, 5 rows by 2 columns (the first column is time domain, second is frequency domain.) The GUI would know which row it should be in by a variable "nthline" which is part of the handles structure, and at the end of the callback function, it will increment by 1 and update the handles structure with guidata(hObject, h). At first, it would create brand new figures with the new data which, while worked, is not what I was asked to do, so I continued to try to get it on the same figure, which led to me adding a variable "firstClick" to the handles structure in the GUI. Upon looking at the value of firstClick for the first pixel selection (where firstClick should be true, where it is initialized and saved to the handles structure,) it is indeed saved as true. So, I update the handles structure to assign false to firstclick with
h.firstClick = false; %h is the handles structure
guidata(hObject, h);
On the second pixel selection, h.firstClick is still true, and so it reopens a new figure, but this is not what I want. Why is there this inconsistency in handles structures across different pixels, and how can I keep the firstClick variable from changing back to true?
Accepted Answer
More Answers (0)
Categories
Find more on Interactive Control and Callbacks 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!