Getting matlab timer to update matlab GUIDE gui?

喜欢而已 提交于 2020-01-03 03:07:09

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/1007385/getting-matlab-timer-to-update-matlab-guide-gui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!