Main Content

addDataSource

Add reference data dictionary to parent data dictionary

Description

example

addDataSource(dictionaryObj,refDictionaryFile) adds a data dictionary, refDictionaryFile, as a reference dictionary to a parent dictionary dictionaryObj, a Simulink.data.Dictionary object.

The parent dictionary contains all the entries that are defined in the referenced dictionary until the referenced dictionary is removed from the parent dictionary. The DataSource property of an entry indicates the dictionary that defines the entry.

Examples

collapse all

Open the data dictionary myDictionary_ex_API.sldd and represent it with a Simulink.data.Dictionary object named myDictionaryObj.

myDictionaryObj = Simulink.data.dictionary.open('myDictionary_ex_API.sldd');

Add the data dictionary mySubDictionary_ex_API.sldd as a reference dictionary to myDictionary_ex_API.sldd.

addDataSource(myDictionaryObj,'mySubDictionary_ex_API.sldd');

Confirm the addition by viewing the DataSources property of variable myDictionaryObj. The property returns the name of the newly referenced dictionary.

myDictionaryObj.DataSources
ans = 

    'myRefDictionary_ex_API.sldd'
    'mySubDictionary_ex_API.sldd'

Input Arguments

collapse all

Parent data dictionary, specified as a Simulink.data.Dictionary object. Before you use this function, represent the target dictionary with a Simulink.data.Dictionary object by using, for example, the Simulink.data.dictionary.create or Simulink.data.dictionary.open function.

File name of data dictionary to reference, specified as a character vector that includes the .sldd extension. The data dictionary file must be on your MATLAB path.

Example: 'mySubDictionary_ex_API.sldd'

Data Types: char

Alternatives

You can use the Model Explorer window to manage reference dictionaries. See Partition Dictionary Data Using Referenced Dictionaries for more information.

Version History

Introduced in R2015a