Main Content

Simulink.data.connect

Create Simulink.data.DataConnection object for a data source

Since R2024a

    Description

    example

    connectionObj = Simulink.data.connect(dataSource) creates a data connection object for a data dictionary, model workspace, or base workspace. The function returns a Simulink.data.DataConnection object representing the connection to the data source.

    example

    connectionObj = Simulink.data.connect(dataSource,TabComplete=tcOption) specifies whether tab completion for the object provides methods, variables, or both methods and variables. Once you create a connection to the data source, your tab completion preference cannot be changed.

    Examples

    collapse all

    • Simulink.data.dictionary.create('myDictionary.sldd');
      dd = Simulink.data.connect('myDictionary.sldd')
      dd = 
      
      DataConnection to myDictionary.sldd

    Create a data connection to the model workspace for model vdp.

    mw = Simulink.data.connect("vdp.slx")
    
    mw = 
    
    DataConnection to vdp.slx

    Create a data connection to the base workspace and configure tab completion to show only variables in the connected data source.

    bw = Simulink.data.connect('base workspace', TabComplete = 'Vars')
    
    bw = 
    
    DataConnectionTCV to base workspace

    Input Arguments

    collapse all

    Name of data source, specified as a string or character vector. Data source can be a data dictionary, model workspace, or base workspace.

    • Data dictionary — Name of data dictionary, including file extension

    • Model workspace — Name of model, including file extension

    • Base workspace — 'base workspace'

    Example: 'myDictionary.sldd'

    Example: "vdp.slx"

    Example: 'base workspace'

    Tab completion preference, specified as 'Methods', 'Vars', or 'All'. By default, tab completion displays the methods available for the connected data source. To configure tab completion to display variables available in the data source, specify 'Vars'. To configure tab completion to display both methods and variables for the data source, specify 'All'.

    Output Arguments

    collapse all

    Connection to data source, returned as a Simulink.data.DataConnection object. If you specify tcOptions as either 'Vars' or 'All', the connection is returned as a Simulink.data.DataConnectionTCV or Simulink.data.DataConnectionTCMV object, respectively. Simulink.data.DataConnectionTCV and Simulink.data.DataConnectionTCMV are both inherited from Simulink.data.DataConnection and support the same methods.

    Version History

    Introduced in R2024a