User`s guide

Desktop Tools and Development Environment
18-19
Nest Cells for Finer Control
You can nest cells in an M-file, including within functions and control statements, such
as for loops and if-then blocks. This gives you greater control over how a published
document appears. This nesting ability also enables you to evaluate subsections of code
on a finer grain when using rapid code iteration.
You can insert white space before the double percent (%%) characters that specify a cell
break (which is also referred to as a cell divider). This helps to improve readability of the
M-file when the cell break is within indented code. In prior releases, the %% characters
had to be in the first column of the code.
The following image shows a simple example of an M-file with nested cells.
If you publish the file to HTML (reducing the size of the images), the cell break nested
within the for loop causes MATLAB to publish each iteration of the for loop as it
evaluates the code in the loop: