How nest functions in GUIDE?

1 visualizzazione (ultimi 30 giorni)
Peter Diaz
Peter Diaz il 25 Mag 2016
Commentato: Peter Diaz il 10 Giu 2016
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

Risposta accettata

Walter Roberson
Walter Roberson il 25 Mag 2016
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 Commento
Peter Diaz
Peter Diaz il 10 Giu 2016
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by