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 string 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.

Input Arguments


Handle to a Simulink model or a string with the model name


Name of the file containing the data.

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


When true, generates a SystemTest™ harness. This option requires dataFile path in addition to model.

Default: false

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


Output Arguments


String 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);
Was this topic helpful?