Defining MATLAB® Commands as Input Cells for Notebook

For information about evaluating the input cells you define, see Evaluating MATLAB® Commands with Notebook.

Defining Commands as Input Cells for Notebook

To define a MATLAB® command in a Word document as an input cell, follow these steps:

  1. Type the command into the M-book as text. For example,

    This is a sample M-book.
    
    a = magic(3)
    
  2. Position the cursor anywhere in the command and select Notebook > Define Input Cell or press Alt+D. If the command is embedded in a line of text, use the mouse to select it. Notebook defines the MATLAB command as an input cell:

    This is a sample M-book.
    
    [a = magic(3)]
    

Note how Notebook changes the character font of the text in the input cell to a bold, dark green color and encloses it within cell markers. Cell markers are bold, gray brackets. They differ from the brackets used to enclose matrices by their size and weight. For information about changing these default formats, see Modifying Styles in the M-Book Template.

Defining Cell Groups for Notebook

You can collect several input cells into a single input cell. This is called a cell group. Because all the output from a cell group appears in a single output cell that Notebook places immediately after the group, cell groups are useful when several MATLAB commands are needed, such as to fully define a graphic.

For example, if you define all the MATLAB commands that produce a graphic as a cell group and then evaluate that cell group, Notebook generates a single graphic that includes all the graphic components defined in the commands. If instead you define all the MATLAB commands that generate the graphic as separate input cells, evaluating the cells generates multiple graphic output cells.

See Evaluating Cell Groups with Notebook for information about evaluating a cell group. For information about ungrouping a cell group, see Ungroup Cells.

Creating a Cell Group for Notebook

To create a cell group, follow these steps:

  1. Use the mouse to select the input cells that are to make up the group.

  2. Select Notebook > Group Cells or press Alt+G.

Notebook converts the selected cells into a cell group and replaces cell markers with a single pair that surrounds the group:

This is a sample cell group.

[date 
a = magic(3) ]

Note the following:

When you create a cell group, Notebook defines it as an input cell unless its first line is an autoinit cell, in which case Notebook defines the group as an autoinit cell.

Defining Autoinit Input Cells for Notebook

You can use autoinit cells to specify MATLAB commands to be automatically evaluated each time an M-book is opened. This is a quick and easy way to initialize the workspace. Autoinit cells are input cells with the following additional characteristics:

Autoinit cells are otherwise identical to input cells.

Creating an Autoinit Cell for Notebook

You can create an autoinit cell in one of the following two ways:

See Evaluating MATLAB® Commands with Notebook for information about evaluating autoinit cells.

Defining Calc Zones for Notebook

You can partition an M-book into self-contained sections, called calc zones. A calc zone is a contiguous block of text, input cells, and output cells. Notebook inserts Microsoft® Word section breaks before and after the section to define the calc zone. The section break indicators include bold, gray brackets to distinguish them from standard Word section breaks.

You can use calc zones to prepare problem sets, making each problem a separate calc zone that can be created and tested on its own. An M-book can contain any number of calc zones.

Creating a Calc Zone

After you create the text and cells that you want to include in the calc zone, define the calc zone by following these steps:

  1. Select the input cells and text to be included in the calc zone.

  2. Select Notebook > Define Calc Zone.

See Evaluating a Calc Zone with Notebook for information about evaluating a calc zone.

Converting an Input Cell to Text with Notebook

To convert an input cell (or an autoinit cell or a cell group) to text, follow these steps:

  1. Select the input cell with the mouse or position the cursor in the input cell.

  2. Select Notebook > Undefine Cells or press Alt+U.

When Notebook converts the cell to text, it reformats the cell contents according to the Microsoft Word Normal style. For more information about M-book styles, see Modifying Styles in the M-Book Template. When you convert an input cell to text, Notebook also converts the corresponding output cell to text.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS