getSlRootInportMap

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

Syntax

  • inputMap = getSlRootInportMap('model',modelname,'MappingMode',mappingmode,'SignalName',signalname,'SignalValue',signalvalue) example
  • [inputMap, hasASignal] = getSlRootInportMap('model',modelname,'MappingMode',mappingmode,'SignalName',signalname,'SignalValue',signalvalue) example
  • inputMap = getSlRootInportMap('model',modelname,'MappingMode','Custom','CustomFunction',customfunction,'SignalName',signalname,'SignalValue',signalvalue) example
  • [inputMap,hasASignal] = getSlRootInportMap('model',modelname,'MappingMode','Custom','CustomFunction',customfunction,'SignalName',signalname,'SignalValue',signalvalue) example

Description

example

inputMap = 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.

example

[inputMap, 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.

example

inputMap = 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.

example

[inputMap,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 map signals to root-level inports using custom mapping modes, you can use getSlRootInport with the Root Inport Mapping dialog box custom mapping capability.

Examples

expand all

Create inport map using Simulink mapping mode

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

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

Create inport map using custom function

Create a vector of inport maps using a custom function

 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

expand all

modelname — Model namestring

Specify the model to associate with the root inport map.

Data Types: char

mappingmode — Simulink mapping modestring

Specify the mapping mode to use with model name and data source. Possible string 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

customfunction — Custom function file namestring

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

signalname — signal namescalar | cell array of strings

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

Data Types: char | cell

signalvalue — signal valuescalar | cell arrays

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

Output Arguments

expand all

inputMap — input mapscalar | vector

Mapping object that defines the mapping of input signals to root-level ports.

hasASignal — signal presence indicatorscalar | vector

A vector of logical values with the same length as inputMap. If the value is true the inputMap has a signal associated with it. If the value is false the inputMap does not have a signal associated with it and will use a ground value as an input

Data Types: logical

More About

expand all

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.

Was this topic helpful?