Main Content

getRootInportMap

Create custom object to map signals to root-level inports

Syntax

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

Description

地图= getRootInportMap('Empty');creates an empty map object,地图.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.

地图= getRootInportMap(model,mdl,Name,Value);creates a map object formodel,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. To create a comma-separated list of variables to map from this object, use thegetInputStringfunction.

地图= getRootInportMap(inputmap,map,Name,Value);overrides the mapping object with the specified property. You can override only the propertiesmodel,blockName, andsignalName.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 thegetInputStringfunction.

Use thegetRootInportMapfunction when creating a custom mapping mode to map data to root-level inports. See the example fileBlockNameIgnorePrefixMap.m, located inmatlabroot/help/toolbox/simulink/examples, for an example of a custom mapping algorithm.

Input Arguments

Empty

Create an empty map object.

Default:none

Name-Value Arguments

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis 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 encloseNamein quotes.

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

地图

Custom object that you can use to map data to root-level input port. To create a comma-separated list of variables to map from this object, use thegetInputStringfunction.

Examples

collapse all

Create an empty custom mapping object.

地图= getRootInportMap('Empty')
地图= 1x0 InputMap array with properties: Type DataSourceName Destination

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,ex_minportsOnlyModel

modelFile = fullfile(matlabroot,'help','toolbox','simulink',...'examples','ex_minportsOnlyModel'); load_system(modelFile); map = getRootInportMap('model','ex_minportsOnlyModel',...“blockName”,'In1','signalname','signalIn1')
地图= InputMap with properties: Type: 'Inport' DataSourceName: 'signalIn1' Destination: [1x1 Simulink.iospecification.Destination]

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

Create a mapping object of vectors.

modelFile = fullfile(matlabroot,'help','toolbox','simulink',...'examples','ex_minportsOnlyModel'); load_system(modelFile); map = getRootInportMap('model','ex_minportsOnlyModel',...“blockName”,{'In1''In2'},...'signalname',{'signalIn1''signalIn2'})
地图= 1x2 InputMap array with properties: Type DataSourceName Destination

Create a mapping object that contains the signalvar2, then overridevar2withvar1

Create a mapping object of vectors.

% Load the model and define variablesmodelFile = fullfile(matlabroot,'help','toolbox','simulink',...'examples','ex_minportsOnlyModel'); load_system(modelFile); modelValue ='ex_minportsOnlyModel'; blockNameValue ='In1'; signalNameValue ='var2'; portType ='Inport';% Define var1 and override var2 with var1signalNameToOverload ='var1'; mapToOverload = getRootInportMap('model'modelValue,...“blockName”,blockNameValue,...'signalName',signalNameToOverload)
地图ToOverload = InputMap with properties: Type: 'Inport' DataSourceName: 'var1' Destination: [1x1 Simulink.iospecification.Destination]

Tips

  • Load the model before running this function.

  • If your custom mapping mode similar to an existing Simulink®地图ping mode, consider using thegetSlRootInportMapfunction instead.

版本sion History

Introduced in R2012b