| SystemTest™ | ![]() |
| On this page… |
|---|
Creating a Spreadsheet Data Test Vector |
The Spreadsheet Data test vector type can be used to read data from Microsoft® Excel® files or .csv files into the SystemTest software. This feature also supports file formats used by the MATLAB xlsread function.
You can read spreadsheet data from multiple sheets, and can read whole sheets or a subset of a sheet.
For a detailed example using the Spreadsheet Data test vector, see Example: Overriding Simulink Inport Blocks Using a Spreadsheet Data Test Vector.
Note For additional technical information and limitations of this feature, see the SystemTest Release Notes. |
To create a Spreadsheet Data test vector:
In the Test Vectors pane, click the New button.
In the Insert Test Vector dialog box, select Spreadsheet Data as the test vector type.

On the General tab, click the Add File button.
Browse to your Microsoft® Excel® spreadsheet file or a .csv file and click Open.
The first sheet of your file is selected by default. If the file has multiple sheets and you want to use them, select the other sheet(s). There is no limit to the number of sheets you can use.
Select the Evaluate Test Vector each time the test is run option if you want to read the file every time the test is run. Leave it unselected if you want to use the same values each time the test is run.
In the case of a Spreadsheet Data test vector, using this option means that data would be read from the spreadsheet file every time the test is run. If you expect the data to change and want to have it read every time, select this option. If you know the data is static or you do not want it to be read each time, unselect the option.
Note that you can use the Evaluate button in the Test Vectors pane any time for an immediate evaluation.
On the Data Selection tab, choose the range to use in the test vector. Enter this information in the Data Range section to select the range.
Specify whether your data is arranged by column or row using the Data is arranged by option.
Then select the specific range using the Read data from option. For example, if you have a file that has data in columns A, B, and C, and there is data in rows 3 through 13 and you want to read all the data, in the Read data from column option, fill in A to C. Then in the starting at row option, enter 3. The SystemTest software will read to the end of the data.
All data in the designated columns is read, from the start-at row through the end of data. Therefore you should only put data in the columns that you want to be read. Extraneous data should be removed if you do not want it to be read. Any blank cells within the read data range will be treated as NaN.
If the first row of your sheet is a header, you can select the First row is a header option to have the SystemTest software exclude it from the data.
In the For Each Selected Sheet section, select the option to determine how the data is arranged when the vector is created. You can have each row (or column) of the spreadsheet be a separate test vector value, or you can have the entire sheet be one test vector value.

See Configuring the Spreadsheet Data Test Vector for more information about these two options.
You can optionally replace strings in the file with values using the String Replacement tab. The table is automatically populated with any strings contained in your sheet(s). If you want to replace each occurrence of a particular string with a value, type the value in the Value column of the table. Then when the test vector is evaluated, that string will be replaced with the value you indicated to populate the test vector.
See Replacing Strings for more information about this option.
Click OK in the Insert Test Vector dialog box. The new vector then appears in the Test Vectors pane.
After creating a Spreadsheet Data test vector, you can edit it any time by selecting it in the table in the Test Vectors tab. If you make any changes to the configuration of the test vector in the SystemTest software, they will be applied immediately. If you make any changes to the underlying spreadsheet, you can have the data reread by clicking the Evaluate button above the test vectors table.
For a detailed example using the Spreadsheet Data test vector, see Example: Overriding Simulink Inport Blocks Using a Spreadsheet Data Test Vector.
Note If the data in your spreadsheet is numeric, it will be a double array in the test vector. If the data contains any strings, it will be a cell array. If the data contains header information and you specified the first row as a header, that will be excluded, and if the remaining data is numeric, it's treated as a double array. |
As shown in step 7 in Creating a Spreadsheet Data Test Vector, you can configure test vector values using the Data Selection tab when you create or edit a Spreadsheet Data test vector.
In the For Each Selected Sheet section, you select the option to determine how the vector is created. You can have each row (or column) of the spreadsheet be a separate test vector value, or you can have the entire sheet be one test vector value.
Treat each row as a test vector value
The Treat each row as a test vector value option means that each row or column (depending on what you selected in the Data is arranged by option) is one test vector value.

In the first case shown here, column A contains values for the parameter Gain. Suppose this column contains 10 values, in rows 2 through 11 (row 1 is a header). The resulting test vector would be a 1-by-10 array containing 10 values. The first value is 1, the second value is 1.1, etc. The ten populated rows result in a total of ten values, each row being one scalar value.
The same is true of the second example shown — that each row is a separate value, except that in this case each value is an array, instead of a single scalar. The first test vector value in this case is the array [1 2 1]. The second test vector value is [2 4 4], etc. If this sheet also had ten rows, there would be ten separate values (each an array of 3 numbers) and the test vector length would be 10.
Treat each selected sheet as a test vector value
The Treat each selected sheet as a test vector value option means that each entire sheet is one test vector value.

If the sheet contains multiple rows and columns, the resulting test vector value is a matrix. In the first example shown here, labeled Simulink Signals, this spreadsheet file contains 3 sheets. Suppose each sheet contained the three columns shown, t, u1, and u2, and had just the three rows of values shown. The resulting test vector would be of length 3 since each sheet is one test vector value and there are three sheets, and each of the three test vector values would be a 3-by-3 matrix.
Suppose the second example, labeled MATLAB Matrix, contained five sheets and each sheet had the three columns shown, each with ten rows of data. The resulting test vector would be of length 5 since each sheet is one test vector value and there are five sheets, and the five test vector values would each be a 10-by-3 matrix, since the sheets have ten rows of data and three columns.
Configuring each sheet to be one test vector value can be useful in a case where you have a test case in each sheet, and each test case is a matrix.
Using Multiple Sheets
If you configure a test vector to use multiple sheets in a file, and you use the Treat each row as a test vector value option, each sheet is read, turned into individual rows, and then appended together. For example, if your file has three sheets containing three, four, and five rows of data respectively, the resulting test vector is a set of row vectors as follows:
row 1 from sheet 1 row 2 from sheet 1 row 3 from sheet 1 row 1 from sheet 2 row 2 from sheet 2 row 3 from sheet 2 row 4 from sheet 2 row 1 from sheet 3 row 2 from sheet 3 row 3 from sheet 3 row 4 from sheet 3 row 5 from sheet 3
If you configure a test vector to use multiple sheets in a file, and you use the Treat each selected sheet as a test vector value option, the resulting test vector will have the same number of values as there are sheets in the file. The same file with three sheets would have three values:
sheet 1 sheet 2 sheet 3
As shown in step 8 in Creating a Spreadsheet Data Test Vector, you can optionally replace strings in the data you read from your spreadsheet files with values using the String Replacement tab when you create or edit a Spreadsheet Data test vector. The table lists any strings contained in your sheet(s), excluding headers if you've specified they are present.
If you want to replace each occurrence of a particular string with a value, type the value in the Value column of the table. Then when the test is run, that string will be replaced with the value you indicated to create the test vector.
An example use case for this feature is that you could have a spreadsheet that contains values for switches, and the values are designated by the strings ON and OFF.

In this example, you might want to replace each instance of ON with a 1 and each instance of OFF with a 0. The String Replacement tab of the Insert Test Vector dialog box would look like the following:

If you want to map the same strings to different values, you have to create separate test vectors and do each replacement mapping separately. For example, in the previous case, you might want the values for Switch A to map to 1 and 0 as shown, but for Switch B you might want to use 100 and 0. In this case, create a test vector that reads only column A and replace ON and OFF with 1 and 0, and then create a second test vector for column B that maps Switch B values to 100 and 0.
![]() | Creating Randomized Test Vectors with Probability Distributions | Creating Simulink Design Verifier Data File Test Vectors | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |