Main Content

getRootInportMap

Create custom object to map signals to root-level inports

Description

example

map = getRootInportMap('Empty'); creates an empty map object, map. Use this map object to set up an empty custom mapping object. For more information, see Tips.

example

map = getRootInportMap(Name=Value); creates a map object for model, mdl, with block names and signal names specified. To create a comma-separated list of variables to map from this object, use the getInputString function. For more information, see Tips.

Examples

collapse all

Create an empty mapping object.

map = getRootInportMap('Empty')
map = 

  1x0 InputMap array with properties:

    Type
    DataSourceName
    Destination
    Status
    BlockName
    BlockPath
    SignalName
    PortNumber

Create a simple mapping object using a MATLAB® time series object.

Create a time series object, signalIn1.

signalIn1 = timeseries((1:10)')
  timeseries

  Common Properties:
            Name: 'unnamed'
            Time: [10x1 double]
        TimeInfo: tsdata.timemetadata
            Data: [10x1 double]
        DataInfo: tsdata.datametadata

Create a mapping object for the time series object for the model,

model = 'ex_three_inports'
model = 
'ex_three_inports'
open_system(model);
map = getRootInportMap('model','ex_three_inports',...
'blockName','In1','signalname','signalIn1')
map = 
  InputMap with properties:

              Type: 'Inport'
    DataSourceName: 'signalIn1'
       Destination: [1x1 Simulink.iospecification.Destination]
            Status: -1
         BlockName: 'In1'
         BlockPath: 'ex_three_inports/In1'
        SignalName: 'signalGain5'
        PortNumber: 1

Create a mapping object using vectors of block names and signal names for the model

Create a mapping object of vectors.

model = 'ex_three_inports';
open_system(model);
map = getRootInportMap('model','ex_three_inports',...
'blockName',{'In1' 'In2'}, ...
'signalname',{'signalIn1' 'signalIn2'})
map=1×2 object
  1x2 InputMap array with properties:

    Type
    DataSourceName
    Destination
    Status
    BlockName
    BlockPath
    SignalName
    PortNumber

Create a mapping object that contains the signal var2, then override var2 with var1.

Load the model and define variables

model = 'ex_three_inports';
open_system(model);
blockNameValue = 'In1';
signalNameValue = 'var2';
portType = 'Inport';

Define var1 and override var2 with var1.

signalNameToOverload = 'var1';
mapToOverload = getRootInportMap('model',model,...
'blockName',blockNameValue,...
 'signalName',signalNameToOverload)
mapToOverload = 
  InputMap with properties:

              Type: 'Inport'
    DataSourceName: 'var1'
       Destination: [1x1 Simulink.iospecification.Destination]
            Status: -1
         BlockName: 'In1'
         BlockPath: 'ex_three_inports/In1'
        SignalName: 'signalGain5'
        PortNumber: 1

Input Arguments

collapse all

Create an empty map object.

Data Types: char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'model','ex_three_inports' associates the model 'ex_three_inports' with the root inport map.

Name of model to associate with the root inport map.

Example: 'ex_three_inports'

Data Types: char | string

Block names of root-level input ports, specified as a cell array. The tool assigns data to ports according to the name of the root-inport block. If the tool finds a data element whose name matches the name of a root-inport block, it maps the data to the corresponding port.

The value for this argument can be:

Block name of root-level input ports.
Cell array containing multiple block names of root-level input ports.

Example: 'In1'

Data Types: char | string

Block paths of root-level input ports, specified as a cell array. The tool assigns data to ports according to the block path of the root-inport block. If the tool finds a data element whose name matches the block path of a root-inport block, it maps the data to the corresponding port.

The value for this argument can be:

Block path of root-level input ports.
Cell array containing multiple block paths of root-level input ports.

Example: 'ex_three_inports/In1'

Data Types: char | string

Signal names to be mapped, specified as a cell array. The tool assigns data to ports according to the name of the signal on the port. If the tool finds a data element whose name matches the name of a signal at a port, it maps the data to the corresponding port.

The value for this argument can be:

Signal name to be mapped.
Cell array containing multiple signal names of signals to be mapped.

Example: 'var2'

Data Types: char | string

Name of mapping object to override, specified as a scalar. The function overrides the inputmap object with the specified property. You can override only the properties model, blockName, and signalName in the mapping object. Load the model before using this function. If you do not load the model first, the function loads the model to make the mapping and then closes the model afterwards. To create a comma-separated list of variables to map from this object, use the getInputString function.

Example: 'newMap'

Data Types: char | string

Output Arguments

collapse all

Custom object to map data to root-level input port, returned as a mapping object. To create a comma-separated list of variables to map from this object, use the getInputString function.

Tips

  • Load the model before running this function. If you do not load the model first, the function loads the model to make the mapping and then closes the model afterwards.

  • If your custom mapping mode is similar to an existing Simulink® mapping mode, consider using the getSlRootInportMap function instead.

  • When creating a custom mapping mode to map data to root-level inports, use the getRootInportMap function . For more information, see Create and Use Custom Map Modes.

Version History

Introduced in R2012b