Why do I have problems using cell mode with functions in the MATLAB Editor?

When I execute cells which contain a function header I receive the following error message.
ERROR: The selected cell cannot be evaluated because it contains an invalid statement.
In general I am confused about how to use cell mode with functions. It works great in script files.

 Accepted Answer

The MATLAB Editor/Debugger cell mode feature is primarily intended to be used with script files.
Use the following tips when working with function files in cell mode:
1. Cells should not contain a function header.
2. Cells will be evaluated in the current workspace. This means in the case of a function, either the function input variables need to be defined in the global workspace or the function needs to be stopped in debug mode when executing cells.
For more information on cell mode, visit this link;
Using Cells for Rapid Code Iteration:

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!