Adding Global Comments

Introduction

The procedures in this section explain how to add a global comment to a Simulink® model so that the comment text appears in the generated file or files where desired. This is accomplished by specifying a template symbol name with a Simulink DocBlock, a Simulink annotation, or a Stateflow® note, or by using a sorted-notes capability that works with Simulink annotations or Stateflow notes (but not DocBlocks). For more information about template symbols, see MPF Template Symbols and Rules.

Using a Simulink® DocBlock to Add a Comment

  1. With the model open, select Library Browser from the View menu.

  2. Drag the DocBlock from Model-Wide Utilities in the Simulink library onto the model.

  3. After double-clicking the DocBlock and typing the desired comment in the editor, save and close the editor. See DocBlock in the Simulink documentation for details.

  4. Right-click the DocBlock and select Mask Parameters. The Block Parameters dialog box appears.

  5. Type one of the following Documentation child into the RTW Embedded Coder Flag field, illustrated below, and then click OK: Abstract, Description, History, ModifiedHistory, or Notes. Template symbol names are case sensitive.

  6. In the Block Properties dialog box, Block Annotation tab, select %<ECoderFlag> as shown in the figure below, and then click OK. The symbol name typed in the previous step now appears under the DocBlock on the model.

  7. Save the model. After you generate code, the code generator places the comment in each generated file whose template has the symbol name you typed. The code generator places the comment in the generated file at the location that corresponds to where the symbol name is located in the template file.

  8. To add one or more other comments to the generated files, repeat steps 1 through 7 as desired.

Using a Simulink® Annotation to Add a Comment

  1. Double-click the unoccupied area on the model where you want to place the comment. See Annotating Diagrams in the Simulink documentation for details.

  2. Type <S:Symbol_name> followed by the comment, where Symbol_name is one of the following Documentation child : Abstract, Description, History, ModifiedHistory, or Notes. For example, type <S:Description>This is the description I want. Template symbol names are case sensitive. (The "S" before the colon indicates "symbol.")

  3. Click outside the rectangle and save the model. After you generate code, the code generator places the comment in each generated file whose template has the symbol name you typed. The code generator places the comment in the generated file at the location that corresponds to where the symbol name is located in the template file.

  4. To add one or more other comments to the generated files, repeat steps 1 through 3 as desired.

Using a Stateflow® Note to Add a Comment

  1. Right-click the desired unoccupied area on the Stateflow chart where you want to place the comment. See Using Notes to Extend Charts in the Stateflow documentation for details.

  2. Select Add Note from the drop down menu.

  3. Type <S:Symbol_name> followed by the comment, where Symbol_name is one of the following Documentation child : Abstract, Description, History, ModifiedHistory, or Notes. For example, type <S:Description>This is the description I want. Template symbol names are case sensitive.

  4. Click outside the note and save the model. After you generate code, the code generator places the comment in each generated file whose template has the symbol name you typed. The code generator places the comment in the generated file at the location that corresponds to where the symbol name is located in the template file.

  5. To add one or more other comments to the generated files, repeat steps 1 through 4 as desired.

Using Sorted Notes to Add Comments

The sorted-notes capability allows you to add automatically sorted comments to the generated files. The code generator places these comments in each generated file at the location that corresponds to where the Notes symbol is located in the template file.

The sorting order the code generator uses is

You can use sorted notes with a Simulink annotation or a Stateflow note, but not with a DocBlock:

The figure below illustrates sorted notes on a model, and where the code generator places each in a generated file.

Here is the relevant fragment from the generated file for the above model:

** NOTES

** Note1: This is the first comment I want
associated with the Notes symbol.
Note2: This is the second comment I want under Notes.
Noteb: This is the third comment. 

**
  


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