Documentation Center

  • Trials
  • Product Updates

getRootInportMap

Create custom object to map signals to root-level inports

Syntax

map = getRootInportMap('Empty');
map = getRootInportMap(model,mdl,Name,Value);
map = getRootInportMap(inputmap,map,Name,Value);

Description

map = getRootInportMap('Empty'); creates an empty map object, map. Use this map object to set up an empty custom 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.

map = getRootInportMap(model,mdl,Name,Value); creates a map object for model, mdl, with block names and signal names specified. 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.

map = getRootInportMap(inputmap,map,Name,Value); overrides the mapping object with the specified property. You can override only the properties model, blockName, and signalName. 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.

Use the getRootInportMap function when creating a custom mapping mode to map data to root-level inports. See BlockNameIgnorePrefix.m for an example of a custom mapping algorithm.

Input Arguments

Empty

Create an empty map object.

Default: none

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'model'

Name of model to associate with the root inport map.

Default: None

'blockName'

Block names of root-level input ports. 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.

Default: None

'signalName'

Signal names to be mapped. 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.

Default: None

'inputmap'

Name of mapping object to override.

Default: None

Output Arguments

map

Custom object that you can use to map data to root-level input port.

Examples

expand all

Empty Mapping Object

Create an empty custom mapping object.

map = getRootInportMap('Empty')
map = 

  1x0 InputMap array with properties:

    Type
    DataSourceName
    Destination

Simple Mapping Object

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

Create a time series object, signalIn1.

signalIn1 = timeseries((1:10)')
Common Properties:
            Name: 'unnamed'
            Time: [10x1 double]
        TimeInfo: [1x1 tsdata.timemetadata]
            Data: [10x1 double]
        DataInfo: [1x1 tsdata.datametadata]

Create a mapping object for the time series object for the model, matlabroot\help\toolbox\simulink\examples\ex_minportsOnlyModel.

load_system ex_minportsOnlyModel;
map = getRootInportMap('model','ex_minportsOnlyModel',...
'blockName','In1','signalname','signalIn1')
map = 

  InputMap with properties:

              Type: 'Inport'
    DataSourceName: 'signalIn1'
       Destination: [1x1 Simulink.iospecification.Destination]

Mapping Object with Vectors

Create a mapping object using vectors of block names and signal names for the model matlabroot\help\toolbox\simulink\examples\ex_minportsOnlyModel.

Create a mapping object of vectors.

load_system ex_minportsOnlyModel;
map = getRootInportMap('model','ex_minportsOnlyModel',...
'blockName',{'In1' 'In2'}, ...
'signalname',{'signalIn1' 'signalIn2'})
map = 

  1x2 InputMap array with properties:

    Type
    DataSourceName
    Destination

Overriding Maps

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

Create a mapping object of vectors.

% Load the model and define variables
load_system ex_minportsOnlyModel;
modelValue = 'ex_minportsOnlyModel';
blockNameValue = 'In1';
signalNameValue = 'var2';
portType = 'Inport';

% Define var1 and override var2 with var1
signalNameToOverload = 'var1';
mapToOverload = getRootInportMap('model',modelValue,...
'blockName',blockNameValue,...
 'signalName',signalNameToOverload)
mapToOverload = 

  InputMap with properties:

              Type: 'Inport'
    DataSourceName: 'var1'
       Destination: [1x1 Simulink.iospecification.Destination]

More About

expand all

Tips

  • Load the model before running this function.

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

See Also

|

Was this topic helpful?