Documentation Center

  • Trial Software
  • Product Updates

Considerations before Migrating to Data Dictionary

Check for Data-Loading Callbacks

You can use model callbacks such as the PreLoadFcn callback to load design data from a file into the base workspace when a model is loaded. For example, the following callback loads design data from the MAT file myData.mat.

load myData

After you migrate to a data dictionary, these callbacks will continue to load design data into the base workspace. Since the model then derives design data from the dictionary, manually remove or comment out these data-loading callbacks.

You can use the Simulink® Manifest Tools to find data-loading callbacks. See Analyze Model Dependencies.

Check Scripts

If you make explicit references to the base workspace by using the handle base in your scripts, consider changing these references. When you move any of your data to a data dictionary, the model no longer looks into the base workspace to find design data.

After you migrate design data to a data dictionary, explicit references to the base workspace cannot resolve and errors can occur.

Consider this example. Here, the script searches the base workspace for variable sensor and sets the parameter enable depending on the value of sensor.noiseEnable.

if evalin('base','sensor.noiseEnable')
	enable = 'Enabled';
else
	enable = 'Disabled';
end 

When you migrate to a data dictionary, replace these explicit references to base as follows:

if evalinGlobalScope(myExampleModel,'sensor.noiseEnable')
	enable = 'Enabled';
else
	enable = 'Disabled';
end 

The evalinGlobalScope function evaluates a variable in the global scope of the specified model. Here, the global scope can be in a data dictionary or the base workspace, if the model is not linked to a dictionary.

Check Tunable Parameters

  • If your model is linked to a data dictionary, Simulink ignores storage class information specified in the tunable parameters table of the model.

  • If you use the Simulink interface to migrate a model to use a data dictionary, Simulink also migrates the storage class information of the model. If your model contains storage class information for variables in the base workspace, Simulink converts these variables into Simulink.Parameter objects during migration. Then, Simulink sets the storage class of these Simulink.Parameter objects using the storage class information from the model.

  • If you migrate this model back to the base workspace, Simulink does not restore the storage class information in the model. To preserve the storage class for these variables, use the parameter objects from the data dictionary. You can also manually reset the storage class information in the model.

  • If you set the DataDictionary property of a model from the command line, convert tunable variables to Simulink.Parameter objects using the tunablevars2parameterobjects function.

Migration of Enumerated Type Definitions

Simulink does not automatically import enumerated class definitions into the data dictionary. Perform the following actions if you want to import enumerated types that are derived from a class definition.

    Note:   You do not need to migrate enumerated types into a data dictionary. You can continue to use enumerated types in the data dictionary, even if they are specified in class definitions.

  1. Rename the class definition file whose enumerated types you want to import into a dictionary.

  2. In the Model Explorer, create or open a data dictionary.

  3. Select the data dictionary node, and click Add > Simulink Enumerated Type.

  4. Create enumerations to match the values in the class definition file. For example, consider the class definition BasicColors.

    classdef BasicColors < Simulink.IntEnumType
    	enumeration
    		Red(0)
    		Yellow(1)
    		Blue(2)
    	end
    end
    

    For this definition, create enumerations in the data dictionary as follows:

Data Dictionary Limitations

  • Simulink cannot automatically migrate variables used only by inactive variant models into a data dictionary.

  • You cannot import certain kinds of design data such as meta class objects and timeseries objects into a data dictionary.

  • The data dictionary does not support models that contain From Workspace blocks. Further, Simulink does not import simulation data such as timeseries objects into the data dictionary. You can migrate such models in one of the following ways.

    • Before migration, replace From Workspace blocks in your model with other source blocks or a combination of source blocks.

    • Migrate the model without replacing From Workspace blocks. After migration, replace the From Workspace blocks.

  • If a model reference hierarchy is already linked to a data dictionary, you can protect a referenced model that is part of the hierarchy. However, if you migrate a model reference hierarchy that includes a protected model, simulation will fail.

    In other words, migrate a model to use a data dictionary before protecting it.

See Also

|

More About

Was this topic helpful?