How nest functions in GUIDE?

2 ビュー (過去 30 日間)
Peter Diaz
Peter Diaz 2016 年 5 月 25 日
コメント済み: Peter Diaz 2016 年 6 月 10 日
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

採用された回答

Walter Roberson
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.
  1 件のコメント
Peter Diaz
Peter Diaz 2016 年 6 月 10 日
Thanks, It helped me to understand that the pushbutton callback converts on the main function when I copied my code, so I had to erase the name of the first function.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by