Main Content

Model Multiple Data Type Behaviors Using a Data Dictionary

This example shows how to use referenced data dictionaries to store multiple sets of data types for a model. This example also shows how to change the data types by switching the referenced data dictionary.

  1. Open the folder containing the example. At the MATLAB®command line, enter:

    cd(fullfile(docroot,'toolbox','fixpoint','examples'))

  2. Copy these files to a local writable folder:

    • ex_data_dictionary.slx— Simulink®model using a data dictionary to store its data types

    • mdl_dd.sldd— Main data dictionary

    • flt_dd.sldd— Referenced data dictionary using floating-point data types

    • fix_dd.sldd— Referenced data dictionary using fixed-point data types

  3. In the folder you copied the files to, open theex_data_dictionarymodel.

    ex_data_dictionary

  4. In the lower left corner of the Simulink Editor, clickto open the dictionary.

    The data dictionary defines the parameters of theGainblocks in theF1andF2subsystems.mdl_ddis associated with a referenced data dictionary,flt_dd, which defines the output data types of the gain blocks in the model’s subsystems.

    In the Model Explorer, in theContentspane, theData Sourcecolumn shows the source data dictionary for each Gain block parameter.

  5. Return to the model. Open theF1subsystem and double-click thea1block. The block gain is specified asf1_a1_param, which is defined in the data dictionary.

In theSignal Attributestab, the block output data type is specified asf1_a1_dt. The data type off1_a1_dtis defined in the referenced data dictionary,flt_dd.

Change Data Types of Model Parameters

Thefix_dd数据字典包含了山姆e entries asflt_dd, but defines fixed-point data types instead of floating-point data types. To use the fixed-point data types without changing the model, replaceflt_ddwithfix_ddas the referenced data dictionary ofmdl_dd.

  1. In the Model Explorer, in theModel Hierarchypane, right-clickmdl_ddand selectProperties.

  2. Remove the referenced floating-point data dictionary. In the Data Dictionary dialog box, in theReferenced Dictionariespane, selectflt_ddand clickRemove.

  3. Add a reference to the fixed-point data dictionary. ClickAddand selectfix_dd. ClickOKto close the dialog box.

  4. In the Model Explorer, right-clickmdl_ddand selectSave Changes.

  5. Return to the Simulink editor and update the model.

    The model now uses fixed-point data types.

Related Examples

More About