Main Content

getSlRootInportMap

Create custom object to map signals to root-level inports using Simulink mapping mode

Description

inMap = getSlRootInportMap('model',modelname,'MappingMode',mappingmode,'SignalName',signalname,'SignalValue',signalvalue) creates a root inport map using one of the Simulink® mapping modes. 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

[inMap, hasASignal] = getSlRootInportMap('model',modelname,'MappingMode',mappingmode,'SignalName',signalname,'SignalValue',signalvalue) returns a vector of logical values specifying whether or not the root inport map has a signal associated with it. To create a comma-separated list of variables to map from this object, use the getInputString function.

example

inMap = getSlRootInportMap('model',modelname,'MappingMode','Custom','CustomFunction',customfunction,'SignalName',signalname,'SignalValue',signalvalue) creates a root inport map using a custom mapping mode specified in customfunction. 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

[inMap,hasASignal] = getSlRootInportMap('model',modelname,'MappingMode','Custom','CustomFunction',customfunction,'SignalName',signalname,'SignalValue',signalvalue) returns a vector of logical values specifying whether or not the root inport map has a signal associated with it. To create a comma-separated list of variables to map from this object, use the getInputString function.

To map signals to root-level inports using custom mapping modes, you can use getSlRootInport with the Root Inport Mapper dialog box custom mapping capability.

example

Examples

collapse all

Create a vector of inport maps using a built-in mapping mode.

openExample('slexAutotransRootInportsExample');
Throttle = timeseries(ones(10,1)*10);
Brake    = timeseries(zeros(10,1));
inputMap = getSlRootInportMap('model','slexAutotransRootInportsExample',...
              'MappingMode','BlockName', ...
              'SignalName',{'Throttle' 'Brake'},...
              'SignalValue',{Throttle Brake});

Create a vector of inport maps using a custom function.

openExample('slexAutotransRootInportsExample');
port1    = timeseries(ones(10,1)*10);
port2    = timeseries(zeros(10,1));
inputMap = getSlRootInportMap('model','slexAutotransRootInportsExample',...
              'MappingMode','Custom', ...
              'CustomFunction','slexCustomMappingMyCustomMap',...
              'SignalName',{'port1' 'port2'},...
              'SignalValue',{port1 port2});

Input Arguments

collapse all

Specify the model to associate with the root inport map.

Data Types: char

Specify the mapping mode to use with model name and data source. Possible values are:

'Index'

Assign sequential index numbers, starting at 1, to the data in the MAT-file, and map this data to the corresponding inport.

'BlockName

Assign data to ports according to the name of the root-inport block. If the block name of a data element matches the name of a root-inport block, map the data to the corresponding port.

SignalName'

Assign data to ports according to the name of the signal on the port. If the signal name of a data element matches the name of a signal at a port, map the data to the corresponding port.

'BlockPath'

Assign data to ports according to the block path of the root-inport block. If the block path of a data element matches the block path of a root-inport block, map the data to the corresponding port.

'Custom'

Apply mappings according to the definitions in a custom file.

Data Types: char

Specify name of file that implements a custom method to map signals to root-level ports. This function must be on the MATLAB® path.

Data Types: char

Specify the signal name of the signal to associate with the root inport map.

Data Types: char | cell

Specify the values of the signals to map to the root inport map. For the list of supported data types for the values, see Choose a Base Workspace and MAT-File Format.

Output Arguments

collapse all

Mapping object that defines the mapping of input signals to root-level ports. To create a comma-separated list of variables to map from this object, use the getInputString function.

A vector of logical values with the same length as inMap. If an element value is true, the inMap output has a signal associated with that index. If an element value is false the inMap output does not have a signal associated with that index. Simulations use ground as the output value for input ports that do not have an associated signal.

Data Types: logical

Tips

  • Load the model before running this function.

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

Version History

Introduced in R2013b