Viewing Output Trajectories

Viewing and Exporting Simulation Data

You can use several approaches to view output trajectories. Some approaches display output trajectories during simulation. Other approaches export signal values to the MATLAB® workspace during simulation for later retrieval and analysis.

The following sections describe several approaches for viewing output trajectories. For additional information about exporting simulation data, see Export Simulation Data.

Using the Scope Block

You can display output trajectories on a Scope block during simulation as illustrated by the following model.

The display on the Scope shows the output trajectory. The Scope block enables you to zoom in on an area of interest or save the data to the workspace.

The XY Graph block enables you to plot one signal against another.

Using Return Variables

By returning time and output histories, you can use the plotting commands provided in the MATLAB software to display and annotate the output trajectories.

The block labeled Out is an Outport block from the Ports & Subsystems library. The output trajectory, yout, is returned by the integration solver. For more information, see Data Import/Export Pane.

You can also run this simulation from the Simulation menu by specifying variables for the time, output, and states on the Data Import/Export pane of the Configuration Parameters dialog box. You can then plot these results using


Using the To Workspace Block

The To Workspace block can be used to return output trajectories to the workspace. The following model illustrates this use:

The variables y and t appear in the workspace when the simulation is complete. You store the time vector by feeding a Clock block into a To Workspace block. You can also acquire the time vector by entering a variable name for the time on the Data Import/Export pane of the Configuration Parameters dialog box, for menu-driven simulations, or by returning it using the sim command (see Data Import/Export Pane for more information).

The To Workspace block can accept an array input, with each input element's trajectory stored in the resulting workspace variable.

Using the Simulation Data Inspector Tool

By configuring your model to log signal data to the base workspace, you can view the output in the Simulation Data Inspector tool. Open the Configuration Parameters > Data Import/Export pane. Set the following parameters:

  • Time: enable

  • States: enable

  • Output: enable

  • Signal logging: enable

  • Format: Structure with time

For more information on the Simulation Data Inspector tool, see Inspect Signal Data with Simulation Data Inspector.

Was this topic helpful?