I've been trying lots of different methods of using a push button callback and I can't seem to find a simple way to detect a click and then do some miscellaneous thing. I'm trying to avoid making the callback a function call since I am trying to update variables in my main loop and run separate functions based on those variables. I could probably do this with global variables but that seems like overkill.
I was hoping for something like this:
press = 0;button1 = uicontrol('style', 'pushbutton', 'string', 'button1', 'callback', 'press = 1');if pressx = x + 1;myfunction(x);end
This doesn't work though since "press" doesn't exist outside of the callback. Next I tried using guidata to save "press" but that didn't work either.
press = 0;button1 = uicontrol('style', 'pushbutton', 'string', 'button1', 'callback', 'press = 1; guidata(figure, press)');press = guidata(figure);if pressx = x + 1;myfunction(x);end