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

3 views (last 30 days)
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

MathWorks Support Team
MathWorks Support Team on 11 Aug 2022
Edited: MathWorks Support Team on 30 Sep 2022
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)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!