In a script(outside of GUI), how to execute button callback function in GUI?
3 次查看(过去 30 天)
显示 更早的评论
Hi, all. I have a GUI program(named myGUI) created by guide(). There are several checkboxes and a button which is used to calculate a measure value and then save it to the file according to the two GUI input values and the status of checkboxes. This button function sometimes takes a long time to finish calculation. In order to choose the optimal value of this measure, I want to use this GUI within a loop.
The script is as follows:
--------------------------
A % Known row vector
B % Known row vector
for i = 1:10
myGUI(A(i), B(i)); % Here, I want to execute the button function in myGUI.
end
---------------------------------------------------------------------
My question is :
1) how to execute the button function of myGUI within the loop?
2) how to decide the status whether myGUI finish its final calculation,
Thanks for any help.
0 个评论
回答(2 个)
Jan
2012-12-13
A good programming style is to move the calculations in a separate function, which is called from the callback, but is available from outside the GUI also. Then you can run the operations from the GUI or in "batch-mode" programmatically.
Using the indirection to call the calculations through calling the GUI is less flexible and more complicated.
The general rul is: Keep the data, the calculations and the GUI separately as consequent as possible. Such a modular concept allows e.g. for modifying the GUI without touching the calculations, and vice versa.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!