Is it possible to use GUI's callback functions with another Matlab program?

1 次查看(过去 30 天)
I've made a GUI program in Matlab that can manage a controller. With it I can comunicate with a controller easily with the usage of callback functions that are implemented in it. Now, I would like to make another program for another purpose and in it I would like to use/call those same functions. Can anyone tell me is this possible to do it this way or I will need to do it differently?

采纳的回答

Jan
Jan 2017-10-6
Did you implement the code for the communication with the controller directly in the callback functions of the GUI? This would be a pity.
Prefer to keep the data, the code for the calculations and the GUIs separated as clear as possible. Then you can modify each of them independent from the other parts. In your case this would have the advantage, that you can call the function for the communication directly without the need of the indirection over the GUI. The callback from the GUI would grab the values of its elements only, and call the external function for the processing.
I recommend to split the code of your GUI callbacks, because this is easier, more flexible and less prone to bugs, than some code to "remote control" the GUI and calling the callbacks magically with constructed inputs.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by