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

조회 수: 1 (최근 30일)
Programerck
Programerck 2017년 10월 6일
답변: Jan 2017년 10월 6일
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