Installation guide

6 Editing and Debugging M-Files
lines of code you want in a cell and then select Cell > Insert Cell Dividers
Around Selection.
Yo u can define a cell at the start of a new empty file, enter code for the cell,
define the start of the next cell, enter its code, and so on. R edefine cells by
defining new cells, removing existing cells, and moving lines of code.
You can set an Editor/Debugger preference to show a faint gray horizontal
line (rule) above each cell that helps distinguish the cells. Select
File > Preferences > Editor/Debugger > Display and in Cell display
options,useShow lines between cells. The horizontal lines do not appear
in the M-file when you print it.
MATLAB does not e xecute the code in lines beginning with
%%,sobesureto
put any executable code for the cell on the following line. For program control
statements, such as
if ... end, a cell must contain both the opening and
closing statements, that is, it must contain both the
if and the end statem ents.
Notethatthefirstcellinafiledoesnothavetobeginwith
%%. MATLAB
automatically understands any lines above the first
%% line to be a cell. If
there a re no cell dividers in an M -file, M ATLAB understands the entire file to
be a single cell.
Cell Titles and Highlighting
After the %%, type a space, followed by a description of the cell. The
Editor/Debugger emphasizes the special meaning of the start of a cell by
making any text following the percent signs appear bold. The text on the
%%
line is called the cell title (like a section title). Including text in cell titles is
optional, however, they improve readability of the file and are used for cell
publishing features.
When the cursor is positioned i n any line within a cell, the Editor/Debugger
highlights the en tire cell with a yellow backgrou nd. Thi s identifies it as
the current cell. For example, it is used w hen you select the Evaluate
Current Cell option on the Cell menu. If you do not want yellow
highlighting for the current cell, change it using preferences. Select
File > Preferences > Editor/Debugger > Display and change the
appropriate Cell display options.
6-136