Main Content

addDataSource

R2026b

Add referenced data dictionaries to parent data dictionary

Description

addDataSource(dictionaryObj,refDictionaries) adds one or more data dictionaries specified by refDictionaries, as referenced dictionaries to a parent Simulink.data.Dictionary object dictionaryObj.

The parent dictionary contains all the entries that are defined in a 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.

example

Examples

collapse all

Open the data dictionary myDictionary_ex_API.sldd.

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

Add the data dictionary myRefDictionary_ex_API.sldd as a referenced dictionary to myDictionary_ex_API.sldd.

addDataSource(myDictionaryObj,"myRefDictionary_ex_API.sldd");

Confirm the addition of the referenced dictionary.

myDictionaryObj.DataSources
ans = 

    'myDictionary_ex_API.sldd'
    'myRefDictionary_ex_API.sldd'

Add two more data dictionaries, myRefDictionary1_ex_API.sldd and myRefDictionary2_ex_API.sldd as referenced dictionaries to myDictionary_ex_API.sldd.

addDataSource(myDictionaryObj,["myRefDictionary1_ex_API.sldd","myRefDictionary2_ex_API.sldd"]);

Confirm the addition of the referenced dictionaries.

myDictionaryObj.DataSources
ans =

    'myDictionary_ex_API.sldd'
    'myRefDictionary1_ex_API.sldd'
    'myRefDictionary2_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 the Simulink.data.dictionary.create or Simulink.data.dictionary.open function.

One or more names of data dictionaries to reference, specified as a string scalar, string array, character vector, or cell array of character vectors. Each data dictionary file name must include the .sldd file extension and the data dictionary file must be on your MATLAB path.

Example: "myRefDictionary_ex_API.sldd"

Example: ["myRefDictionary1_ex_API.sldd","myRefDictionary2_ex_API.sldd"]

Data Types: string | char | cell

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

expand all