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.
Best Answer