Desktop Tools and Development Environment Previous page   Next Page

Rapid Code Iteration Using Cells

When working with MATLAB, you often experiment with your code--modifying it, testing it, and updating it--until you have an M-file that does what you want. Use the cell features in the MATLAB Editor/Debugger to make the experimental phase of your work with M-file scripts easier. You can also use cell features with function M-files, but there are some restrictions--see Using Cells in Function M-Files.

If you are viewing this document in the Help browser, you can watch the Rapid Code Iteration Using Cells video demo for an overview of the major functionality.

The overall structure of many M-file scripts seems to naturally consist of multiple sections. Especially for larger files, you often focus efforts on a single section at a time, refining the code in just that section. To facilitate this process, use M-file cells, where a cell is a defined section of code.

This is the overall process of using cells for rapid code iteration:

  1. In the MATLAB Editor/Debugger, enable cell mode. Select Cell -> Enable Cell Mode. Items in the Cell menu become selectable and the cell toolbar appears.
  2. Define the boundaries of the cells in an M-file script using cell features. Cells are denoted by a specialized comment syntax. For details, see Defining Cells.
  3. Once you define the cells, use cell features to navigate quickly from cell to cell in your file, evaluate the code in a cell in the base workspace, and view the results. To facilitate experimentation, use cell features to modify values in cells and then reevaluate them, to see how different values impact the result. For details, see Navigating and Evaluating with Cells.
  4. Cells are also useful if you want to share your results by publishing your work in a presentation format, such as an HTML document. For details, see Publishing to HTML, XML, LaTeX, Word, and PowerPoint Using Cells.

    Image of Editor showing Cell menu and cell toolbar. The current cell is highlighted (in yellow).


Previous page  Error Breakpoints Defining Cells Next page

© 1994-2005 The MathWorks, Inc.