Generate Simulink Verification and Validation harness model


[harnessFilePath] = slvnvmakeharness(model)
[harnessFilePath] = slvnvmakeharness(model, dataFile)
[harnessFilePath] = slvnvmakeharness(model, dataFile, harnessOpts)


[harnessFilePath] = slvnvmakeharness(model) generates a test harness from model, which is a handle to a Simulink® model or a character vector with the model name. slvnvmakeharness returns the path and file name of the generated harness model in harnessFilePath. slvnvmakeharness creates an empty harness model; the test harness includes one default test case that specifies the default values for all input signals.

[harnessFilePath] = slvnvmakeharness(model, dataFile) generates a test harness from the data file dataFile.

[harnessFilePath] = slvnvmakeharness(model, dataFile, harnessOpts) generates a test harness from model using the dataFile and harnessOpts, which specifies the harness creation options. Requires '' for dataFile if dataFile is not available. The default dataFile argument creates a test harness with a single test case with default values for the inputs.

Input Arguments


Handle to a Simulink model or a character vector with the model name


Refers to a structure created by the slvnvlogsignals or the slvnvmergedata functions. It contains information about the model, its input and output ports, and any preexisting test signals. This argument can either be the structure itself or the name of the .mat file containing this structure. Use this parameter when you have previously logged test data that you wish to import into a new test harness.

Default: ''


A structure whose fields specify the configuration for slvnvmakeharness:


Specifies the file path for creating the harness model. If an invalid path is specified, slvnvmakeharness does not save the harness model, but it creates and opens the harness model. If this option is not specified, the slvnvoptions object is used. If this option is not specified, slvnvmakeharness generates a new harness model and saves it in the MATLAB® current folder.

Default: ''


Generates the test harness model that includes model in a Model block. When false, the test harness model includes a copy of model.

Default: true

    Note:   If your model contains bus objects and you set modelRefHarness to true, in the Configuration Parameters > Diagnostics > Connectivity pane, you must set the Mux blocks used to create bus signals parameter to error. For more information, see Prevent Bus and Mux Mixtures.


When true, the Signal Builder block in the harness model has signals only for input signals used in the model. The Simulink Design Verifier™ software must be available, and model must be compatible with the Simulink Design Verifier software to detect the used input signals.

Default: false

    Note:   To create a default harnessOpts object, at the MATLAB command prompt, type:


Output Arguments


Character vector containing the path and file name of the generated harness model


Create a test harness for the sldemo_mdlref_house model using the default options:

[harnessfile] = slvnvmakeharness('sldemo_mdlref_house', '', harnessOpts);

Introduced in R2010b

Was this topic helpful?