Main Content

map

Class: sltest.testmanager.TestInput
Namespace: sltest.testmanager

Map test input to system under test

Syntax

map(input,Name,Value)

Description

map(input,Name,Value) maps the test input data input to the system under test.

Input Arguments

expand all

The test input to map, specified as a sltest.testmanager.TestInput object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is 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 enclose Name in quotes.

Example: 'Mode',4,'CustomFunction','mapfcn'

Mapping mode, specified as the comma-separated pair consisting of 'mode' and an integer corresponding to the desired mapping mode:

  • 0 — Block name

  • 1 — Block path

  • 2 — Signal name

  • 3 — Port order (index)

  • 4 — Custom

For more information on mapping modes, see Map Root Inport Signal Data.

Example: 'Mode',2

Name of function used for custom mapping, specified as the comma-separated pair consisting of 'customFunction' and a character vector. This argument is optional and valid only when mode is set to 4.

Example: 'CustomFunction','mapfcn'

Option to compile or not compile the model when performing input mapping, specified as the comma-separated pair consisting of 'CompileModel' and false or true.

Example: 'CompileModel',false

Examples

expand all

This example shows how to add data from a Microsoft® Excel® spreadsheet and map it to a test case. Only the two sheets that have data are added and mapped.

Load the Example Model

open_system('slexAutotransRootInportsExample');

Create a New Test File

tf = sltest.testmanager.TestFile('input_test_file.mldatx');

Get the Test Suite and Test Case Objects

ts = getTestSuites(tf);
tc = getTestCases(ts);

Add the Example Model as the System Under Test

setProperty(tc,'Model','slexAutotransRootInportsExample');

Add Excel® Data to Inputs Section and Specify Sheets to Add

excelfile = 'sltestExampleInputs.xlsx';
input = addInput(tc,excelfile,'Sheets',["Acceleration","Braking"]);

Map the Input Signal for the Sheets by Block Name

map(input(1),0);
map(input(2),0);

Version History

Introduced in R2015b