Documentation Center

  • Trial Software
  • Product Updates

Reading Excel® Files Using the Spreadsheet Data Test Vector

This example shows how to read test data from spreadsheet files so that you can easily iterate over your algorithm or model for testing. It can read any files that your system would be able to read using the MATLAB function xlsreadxlsread. On Windows platforms this includes .XLS files, .CSV and others. On non-Windows platforms, only .XLS files are supported.

The following examples show how to read test data for testing Simulink® Models using the Spreadsheet Data test vector, but the same process can be applied for testing any algorithm.

Overview of Spreadsheet Data Test Vector

There are a total of 4 tabs within the Spreadsheet Data test vector.

This video gives an overview of the different parts of the Spreadsheet Data Test Vector by showing how to use the following tabs:

  • General tab for adding spreadsheets

  • Data Selection tab for configuring which data to read

  • String Replacement tab for making substitutions in read data

  • Grouping tab for grouping or ungrouping the test vector

Watch the video (1 min, 28 sec)Watch the video (1 min, 28 sec)

How to Read Scalar Test Data

Scalar test data is defined as test data laid out in a spreadsheet such that each row represents a different test case for your algorithm. Each of these rows are read and used as a test vector value.

This video describes how to read in scalar test data that represents values for a Simulink Block Parameter through the following actions:

  • Create a new Spreadsheet Data test vector.

  • Add the file(s).

  • In the Data Selection tab, read from the columns containing the test data.

Watch the video (2 min, 01 sec)Watch the video (2 min, 01 sec)

How to Read Matrix Test Data

Matrix test data is defined as test data laid out in multiple spreadsheets such that the data from each spreadsheet represents a different test case. Each of these sheets are read and used as a test vector value.

This video describes how to read Simulink signal test data from multiple sheets in a single file through the following actions:

  • Create a new Spreadsheet Data test vector.

  • Add the file(s).

  • In the Data Selection tab, read from the columns containing the test data.

  • In the Data Selection tab, select "First row is a header"

  • In the Data Selection tab, select "Treat each sheet as a test vector value."

Watch the video (1 min, 23 sec)Watch the video (1 min, 23 sec)

How to Replace Strings with Numerical Values in Test Data

The Spreadsheet Data test vector allows you to make string replacements in your read data with numerical constants. The data being used as test vector values in SystemTest is changed, but the data in spreadsheets remains unaffected.

This video describes how to read Simulink signals represented by the strings ON and OFF and replace them with 1 and 0, respectively, through the following actions:

  • Create a new Spreadsheet Data test vector.

  • Add the file(s).

  • In the Data Selection tab, read from the columns containing the test data.

  • In the Data Selection tab, select "First row is a header"

  • In the Data Selection tab, select "Treat each sheet as a test vector value."

  • In the String Replacement tab, edit the table to replace ON with 1 and OFF with 0.

Watch the video (1 min, 49 sec)Watch the video (1 min, 49 sec)

Was this topic helpful?