MATLAB Examples

Importing Microsoft® Excel® Data

Test a model using inputs stored in Microsoft Excel.

Contents

This example shows how to create a test case in the test manager and use the Simulink® Root Inport Mapping tool to load mapping data from a Microsoft® Excel® file. The Root Inport Mapping tool supports Microsoft Excel spreadsheets only for Microsoft Windows®. The example model used is a modified version of a shipping Simulink® example that models the Automatic Transmission Controller. For more information, see sldemo_autotrans.

Create a Test File

Enter sltestmgr into the MATLAB command prompt to open the test manager.

Open example model sltestExcelExample.

mdl = 'sltestExcelExample';
open_system(mdl);

1. In the test manager toolbar, select New > Test File. Save the file to a writable directory. The test manager creates a test file with an empty baseline test case.

2. In the test browser, select the test case. In the test editor, under the System Under Test section, click the Use current model button.

Configure the External Inputs.

1. Expand the Inputs section of the test case.

2. To include the input data in the test results, click Include external inputs/signal builder data in test result.

3. Under the External Inputs table, click Add.

4. In the Add Input dialog box, for File, enter sltestExampleInputs.xlsx. Click Add.

5. In the Add Input dialog box,

  • Set Sheet : Acceleration
  • Set Mapping Mode : Block Name.
  • Click Map Inputs.
  • Click Add.

The Mapping Mode controls the method used to map data from the Microsoft Excel sheet to root-level Inport blocks in the model. For more information, see Map Root Inport Signal Data.

The test case shows the inputs mapped.

Run the Test

1. In the toolbar, click Run.

2. In the Results and Artifacts pane, you can plot signals from the external inputs or the simulation output.

close_system(mdl, 0);
clear mdl;