Getting Matlab timer to update matlab GUIDE gui?

I have a matlab timer object. It updates the global variable FOO once per second.

I have a GUI GUID for Matlab, with several controls and a frame for one frame. The graph frame is updated by some GUI controls, and it is updated by the timer object.

Basically, there are two global variables FOO and BAR. The timer updates the FOO, the GUI controller updates the BAR. Updates for FOO or BAR need to update the GUI.

How to do it?

Thanks, John

+1
source share
1 answer

You cannot set the clock to a variable. There is no callback for this. However, both FOO and BAR are updated: either


FOO by timerFcn

BAR on widget callbacks


You need to make a function:

updatePlot% updates the chart to display the new FOO or BAR values

and both functions that update FOO or BAR call updatePlot as one of their last responsibilities.

I would also recommend against using global variables. There are better ways to do this. I am a fan of GETAPPDATA and SETAPPDATA. Check out this video I made about it.

http://blogs.mathworks.com/videos/2005/105/03/guide-video-part-two/

You can also try nested functions.

+3
source

All Articles