base = addBaselineCriteria(tc,file)
adds a MAT-file, Simulation Data Inspector (SDI) MLDATX file, or Microsoft®
Excel® file as baseline criteria to a baseline test case. If
file is an Excel file that has multiple sheets, each is added to the test
case as a separate baseline set.
base = addBaselineCriteria(tc,file,'RefreshIfExists',true)
adds the baseline criteria to the test case, replacing the baseline criteria if
the test case already had one.
base = addBaselineCriteria(tc,excel,'Sheets',sheets,Name,Value)
specifies the sheets from the Excel to
include in the baseline criteria and uses additional options specified by one or
more Name,Value pair arguments.
Test case that you want to add the baseline criteria to, specified as an
sltest.testmanager.TestCase
object.
file — Excel, MAT, or SDI MLDATX file name and path character vector
File and path name of the baseline criteria file, specified as a character
vector. You can specify a MAT-file, Simulation Data Inspector MLDATX file,
or a Microsoft
Excel file.
Example: 'C:\MATLAB\baseline_API.mat'
excel — Excel file name and path character vector
File and path name of the Excel
file to use as the baseline criteria, specified as a character
vector.
Example: 'C:\MATLAB\baseline.xlsx'
sheets — Names of Excel sheets to add character vector | string | array of strings
Names of sheets from Excel file
to add, specified as a character vector, string, or array of
strings.
Example: 'signals',
["Heater","Plant"]
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 encloseNamein quotes.
Example: 'Ranges','B1:C4','RefreshIfExists',false
Ranges — Range of cells from sheet character vector | string | array of strings
Ranges of cells from the sheets that you add as baseline criteria,
specified as a character vector, a string, or an array of strings. The
ranges you specify must correspond to the sheets you specify. For
example, if you specify one sheet, specify one range. If you specify a
cell array of sheets, each value in the 'Ranges' cell
array must correspond to a sheet in the 'Sheets' cell
array. Specify an empty range to use the entire sheet.
Option to replace the test case baseline criteria, specified as a
Boolean. Use false to return an error if the test
case already has baseline criteria, that is, to prevent overwriting the
baseline. Use true to add the baseline criteria,
replacing the existing baseline.
SeparateBaselines — Specify separate baselines true (default) | false
Option to use each sheet in specified by the
'Sheets' argument as a separate baseline,
specified as true or false.
base — Baseline criteria sltest.testmanager.BaselineCriteria
object | array of sltest.testmanager.BaselineCriteria objects
Baseline criteria added to the test case, returned as an sltest.testmanager.BaselineCriteria object or an array of
sltest.testmanager.BaselineCriteria
objects.
% Open the model for this example
openExample('sldemo_absbrake');
% Create the test file, test suite, and test case structure
tf = sltest.testmanager.TestFile('API Test File');
ts = createTestSuite(tf,'API Test Suite');
tc = createTestCase(ts,'baseline','Baseline API Test Case');
% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);
% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');
% Add baseline criteria from file
baseline = addBaselineCriteria(tc,'C:\MATLAB\baseline_API.mat');
Use MicrosoftExcel File as Baseline
Use an Excel file as baseline,
overwriting the existing baseline on the test case.
% Open the model for this example
openExample('sldemo_absbrake');
% Create the test file, test suite, and test case structure
tf = sltest.testmanager.TestFile('Excel Test File');
ts = createTestSuite(tf,'Excel Test Suite');
tc = createTestCase(ts,'baseline','Baseline Excel Test Case');
% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);
% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');
% Add baseline criteria from file
baseline = addBaselineCriteria(tc,...'C:\MATLAB\myexcel.xlsx','RefreshIfExists',true);
Add One Baseline from a MicrosoftExcel File
Use an Excel file as baseline,
creating one baseline even if the Excel file has multiple sheets.
% Open the model for this example
openExample('sldemo_absbrake');
% Create the test file, test suite, and test case structure
tf = sltest.testmanager.TestFile('Excel Test File');
ts = createTestSuite(tf,'Excel Test Suite');
tc = createTestCase(ts,'baseline','Baseline Excel Test Case');
% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);
% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');
% Add baseline criteria from file
baseline = addBaselineCriteria(tc,...'C:\MATLAB\myexcel.xlsx','SeparateBaselines',false);
Specify Sheets and Cell Range in a Baseline
Select three sheets from an Excel
file to use as the baseline. For each sheet, specify a range of cells.
% Open the model for this example
openExample('sldemo_absbrake');
% Create the test file, test suite, and test case structure
tf = sltest.testmanager.TestFile('Excel Test File');
ts = createTestSuite(tf,'Excel Test Suite');
tc = createTestCase(ts,'baseline','Baseline Excel Test Case');
% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);
% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');
% Create sheets and ranges arrays
sheets = ["HotTemp", "ColdTemp", "NominalTemp"];
ranges = ["B2:C30", "D2:E30", "B2:C30"];
% Add baseline criteria from file, using the sheets and cell ranges specified
baseline = addBaselineCriteria(tc,...'C:\MATLAB\myexcel.xlsx','Sheets',sheets,'Ranges',ranges);
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.