Main Content

Model Requirements for Importing Data

Before you can analyze and preprocess the estimation data, you must assign the data to the model ports or signals. In order to assign the data, the Simulink® model must contain one of the following elements:

  • Root-level model Inport block

    Note

    You do not need an Inport block if your model already contains a fixed input block, such as a Step block.

  • Root-level model Outport block

  • Logged signal, which can be a root-level signal in the model or a signal in a model subsystem

    To enable signal logging for a signal, in the Simulink Editor, select the signal, click the Simulation Data Inspector button arrow and click Log Selected Signals. For more information, see Save Signal Data Using Signal Logging.

  • Simscape™ block

When you create an experiment, as described in Create Experiment, the top level input and output ports as well as logged signals are selected by default. You can add or remove the input and output signals using the experiment editor. In the Edit Experiment dialog box, the rows in the Inputs section correspond to the root-level Inport blocks of the model.

Edit Experiment dialog box with the populated Output Signal table under the Outputs section on top and the populated Input Signal table under the Inputs section on the bottom

Similarly, the rows in the Outputs section correspond to either the root-level Outport blocks or logged signals in the model.

Select Input Signals

You can add the Inport block in the experiment editor open the Select Inputs dialog box by clicking the Select Inputs button in the Inputs section. You can select the Inport block you want by selecting the check box corresponding to it and clicking OK.

For example, there is only one Inport block for the engine_idle_speed model.

Select Inputs dialog box with the selected Inport block

To obtain the engine_idle_speed model, run the following command.

openExample('sldo/EngineIdleSpeedModelExample')

In the Edit Experiment dialog box, to import the input data from the MATLAB® workspace, select Select time and data vectors from MATLAB workspace and select the workspace variable in the drop-down list. You can also specify input data as a timetable object, as a timeseries object, or using array notation. To do so, select Specify time and data as timetable, timeseries, or in array notation and specify the data in the text box. The following figure specifies input data in the array notation [time,iodata(:,1)]. To learn more about importing data, see Import Data.

The Inputs section of the Edit Experiment dialog box with the input data specified using array notation

Select Output Signals

You can add the Output block in the Edit Experiment dialog box by clicking Select Signals in the Outputs section to open the Select Outputs dialog box. You can select the Outport block you want by clicking the check box corresponding to it, and clicking OK.

Similarly, for models containing Simscape blocks, to select a Simscape block, in the Outputs section, click Select Signals. Now directly click on a Simscape block from the Simulink model. This populates the Create Signal Set dialog box with the Simscape variables corresponding to the block. You can select the variable you want by selecting the check box corresponding to it and clicking OK.

For example, there is only one Outport block for the engine_idle_speed model.

Select Outputs dialog box with the selected Outport block

In the Edit Experiment dialog box, to import the output data from the MATLAB workspace, select Select time and data vectors from MATLAB workspace and select the workspace variable in the drop-down list. You can also specify output data as a timetable object, as a timeseries object, or using array notation. To do so, select Specify time and data as timetable, timeseries, or in array notation and specify the data in the text box. The following figure specifies output data in the array notation [time,iodata(:,2)]. To learn more about importing data, see Import Data.

The Outputs section of the Edit Experiment dialog box with the output data specified using array notation

Related Examples

More About