You can create custom map modes to supplement the map modes that the Root Inport Mapper tool provides (see Choose a Map Mode).
For a summary of the other steps involved in using the Root Inport Mapper tool, see Import and Mapping Workflow.
If you do not want to use the map modes in the Root Inport Mapper tool, create a custom mapping file function. For example, consider creating a custom mapping file function if:
Your signal data contains a common prefix that is not in your model.
You want to map a signal explicitly.
When the data contains a signal name that does not match one of the block names, a custom mapping function is useful for block name mapping.
For examples, see these files in the folder
Custom mapping file function that ignores the prefix of a signal name when importing signals
MAT-file of signal data to be imported
Model file into which you can import and map data
In addition, see Using Mapping Modes with Custom-Mapped External Inputs.
To create a custom mapping file function:
Create a MATLAB® function with these input parameters:
Signal names specified as a cell array of character vectors
Signals specified as a cell array of signal data
In the function, call the
function to create a variable that
contains the mapping object (for an example, see
Save and close the MATLAB function file.
Add the path for the new function to the MATLAB path.
To use the custom mapping file function:
Open the model that you want to import data to (for example,
Open the Configuration Parameters dialog box for the model and select the Data Import/Export pane.
In the Load from workspace section, click Connect Input.
Import your signal (for example,
In the MAP TO MODEL section of the toolstrip, click Custom.
In the Custom text box, select the MATLAB function file (for example,
BlockNameIgnorePrefixMap.m) using the browser.
By default, this text box contains
slexcustomMappingMyCustomMap, which is the custom
function for Attaching Input Data to External Inputs via Custom Input Mappings.
The Root Inport Mapper tool parses your custom code. Parsing reorders output alphabetically and verifies that data types are consistent.
Click Options and select the Compile check box.
The model is compiled and the Root Inport Mapper tool gets updated.
To understand the mapping results, see Understand Mapping Results.
Save and close the model.
After you save the mapping definition for a model, you can automate data loading. The next time that you load input data of the same signal group into the workspace, the model uses the mapping definition during simulation. For more information, see Alternative Workflows to Load Mapping Data.
If your custom mapping mode is similar to a Simulink® mapping mode, use the
getSlRootInportMap function in
your custom mapping file function to perform the data mapping.
For an example of a custom mapping function that uses this function, see Using Mapping Modes with Custom-Mapped External Inputs.
function to supply a set of input variables to:
A list of input variables that you can paste in the Configuration Parameters > Data Import/Export > Input parameter