How nest functions in GUIDE?
1 次查看(过去 30 天)
显示 更早的评论
The problem are not easy as it seems. I'm programming the GUI of a script where some data (numbers) are entered, then the program does its complex calculations and places the results in 'Static text'; this is activated by pressing a button called 'calculate'. Then, programming is done with functions, total'm 16, and I've done is to put all that code in the callback button 'calculate', but when I run nothing happens. Is it because the functions of the GUI end in 'return' while the scheduled end in 'end'?.
function pushbutton1_Callback(hObject, eventdata, handles,principal)
%hObject handle to pushbutton1 (see GCBO)
function 1
...return
function 2
...return
function 3
...return
etc
0 个评论
采纳的回答
Walter Roberson
2016-5-25
Nested functions must have an end matching their function statement, and they must be enclosed in a function that has an end matching its function statement.
Any one .m file must be consistent: its functions can either all not have the matching end statement (which GUIDE generates) or its functions can all have the matching end. It is not permitted to mix the two styles in one .m .
In order to put nested functions into a .m generated by GUIDE, you would need to manually add matching end statements for the generated code.
You could also store the containing function into a different .m . GUIDE does not require that all functions be in the one single .m file that it generates.
更多回答(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!