获取matlab定时器来更新matlab的GUIDE gui? [英] Getting matlab timer to update matlab GUIDE gui?
问题描述
我有一个matlab定时器对象。它每秒更新一次全局变量FOO。
I have a matlab timer object. It is updating a global variable FOO once per second.
我有一个matlab GUIDE GUI,有几个控件和一个绘图框。
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.
基本上,有两个全局变量FOO和BAR,它们由一些GUI控件更新,并由定时器对象更新。定时器更新FOO,GUI控制更新BAR。
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.
如何做到这一点?
感谢
John
Thanks John
推荐答案
您不能对变量进行监视。没有回调。但是,FOO和BAR都正在更新:
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由timerFcn
FOO by timerFcn
BAR由窗口回调
您需要创建一个函数:
updatePlot%更新绘图以反映FOO或BAR
updatePlot %updates the plot to reflect new values of FOO or BAR
的新值,并具有更新FOO或BAR的函数调用updatePlot作为他们最后的职责之一。
and have both of the functions that update either FOO or BAR call updatePlot as one of their last duties.
我也建议不要使用全局变量。有更好的方法来做到这一点。我是GETAPPDATA和SETAPPDATA的粉丝。看看我制作的这部影片。
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.
这篇关于获取matlab定时器来更新matlab的GUIDE gui?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!