Main Content

sltest.testmanager.registerTestAdapter

Register adapter to convert test data

Description

example

sltest.testmanager.registerTestAdapter(adapterfcn,adapterdefault) registers an adapter function to convert an Excel® or MAT file that contains test data to a format supported by the Test Manager. For information about the supported Excel format, see Microsoft Excel Import, Export, and Logging Format.

Examples

collapse all

Create and register a function to format a MAT file to use in the Test Manager. This example assumes that you have a MAT file that has x, y, and z parameters and xin and yin inputs.

Create a function that converts a baseline test parameter set in the MAT file.

function Adapter_InputBaselineParamSet(test,externalMATFile)
   load(externalMATFile);
   
   % Set model property for the test case
   setProperty(test,'Model',mdl_name);

   % Save external file parameters to a supported format
   % MAT file and add parameter set to test case
   save('param.mat','x','y','z');
   paramset = addParameterSet(test,'FilePath',...
       'param.mat','SimulationIndex',1) 

   % Save external file inputs to a supported format MAT
   % file and add inputs to test case
   save('input.mat','xin','yin');
   inputs = addInput(test,'input.mat');
   inputs.map(3);                         

   % Capture baseline critera and add to test case
   captureBaselineCriteria(test,'base.mat',true);
   

Then register the function by using its function handle.

sltest.testmanager.registerTestAdapter(...
    @Adapter_InputBaselineParamSet,true); 

Input Arguments

collapse all

Adapter function name, specified as a function handle. The adapter function specifies how to convert an Excel or MAT test data file into a format supported by the Test Manager.

Whether to use the specified adapter as the default for the test case, specified as a numeric or logical 1 (true) or 0 (false). When you set the adapterdefault input to 1 or true, the test case uses specified adapter even if you previously registered a different adapter.

Version History

Introduced in R2022b