Question

I have a matlab timer object. It is updating a global variable FOO once per second.

I have a matlab GUIDE GUI, with a couple of controls, and a single plot frame. The plot frame gets updated by some of the GUI controls, and it gets updated by the timer object.

Basically, there are two global variable FOO and BAR. The timer updates FOO, the GUI controls updates BAR. updates to either FOO or BAR need to update the GUI.

How to do this?

Thanks John

Was it helpful?

Solution

You can NOT put a watch on a variable. There is no callback for that. However, both FOO and BAR are being updated by either:


FOO by timerFcn

BAR by widget callbacks


You need to make a function:

updatePlot %updates the plot to reflect new values of FOO or BAR

and have both of the functions that update either FOO or BAR call updatePlot as one of their last duties.

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

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

You could also try nested functions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top