Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop Embedded Coder   

Creating a Data Dictionary for a Model

In this procedure, you create a data dictionary for a model using Data Object Wizard, inspect the data dictionary, and generate code. Definitions for the data objects in the dictionary are generated into the model source file (model.c).

Using Data Object Wizard

  1. Open the demo model rtwdemo_mpf by clicking the link or by typing rtwdemo_mpf in the MATLAB Command Window.

    In this model,

    • A, B, and C are input signals, and L and Final are output signals.

    • Subsystem1 receives inputs A and E, and contains constants G1 and G2. Signal E is an output from Data Store Read1.

    • Subsystem2 receives inputs C and D. Signal D is an output from Data Store Read2. There is a constant in Subsystem2 named G3. Also, this subsystem has a Unit Delay block whose state name is SS.

  2. Double-click the Stateflow chart and notice it has constants F1, Gain1, and Gain2, as shown below:

  3. Change to a work directory that is not on an installation path and save the model in that work directory. The Real-Time Workshop software does not allow you to generate code from an installation directory.

  4. Double-click the Invoke Data Object Wizard button on the model. Or, type dataobjectwizard('rtwdemo_mpf') in the MATLAB Command Window. Data Object Wizard opens and rtwdemo_mpf appears in the Model name field, as shown below.

  5. Click Find on Data Object Wizard. After a moment, the model's parameters and signals appear in Data Object Wizard. These "data objects" make up the data dictionary.

  6. Click Check All, to select all data objects for the data dictionary.

  7. In the Choose package for selected objects field, select mpt. For an explanation of "package," see Overview of the Data Dictionary.

  8. Click Apply Package. Data Object Wizard associates the selected data objects with the mpt package, as shown below.

  9. Click Create. Data Object Wizard creates a data dictionary, consisting of data objects for the selected parameters and signals. Data Object Wizard removes the objects from its object view. Also, the objects are added to the MATLAB workspace, as shown below.

  10. Close Data Object Wizard.

Inspect the Data Dictionary

You can verify that each data object you selected in Data Object Wizard is in the data dictionary, using the Model Explorer:

  1. Open the Model Explorer.

  2. In the left pane, select Base Workspace. Notice that all data objects that you placed in the data dictionary appear in the middle pane.

  3. In the middle pane, select data objects one at a time, and notice their property values in the right pane. The figure below shows this for signal A. All of the data objects have default property values. Note that for an mpt data object, the default in the Storage class field is Global (Custom). For descriptions of the properties on the Model Explorer, see Setting Property Values for Simulink Data Objects.

Generate and Inspect Code

  1. In the left pane of the Model Explorer, expand the rtwdemo_mpf node.

  2. In the left pane, click Configuration (Active).

  3. In the center pane, click Real-Time Workshop. The active Real-Time Workshop configuration parameters appear in the right pane.

  4. Click the Report tab.

  5. In the Report tab, select Create code generation report

  6. Select the General tab. Select Generate code only, and then click Generate code. After a few moments, the names of the generated files are listed on the Real-Time Workshop Report, as shown below.

  7. Open and inspect the content of the model source file rtwdemo_mpf.c. The following data objects in the data dictionary are initialized in this file.

    real_T F1 = 2.0;
    real_T G1 = 6.0;
    real_T G2 = -2.6;
    real_T G3 = 9.0;
    real_T Gain1 = 5.0;
    real_T Gain2 = -3.0;

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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