To capture signal data from a simulation, usually you can use signal logging. Mark the signals that you want to log and enable signal logging for the model. For details, see Configure a Signal for Logging and Enable Signal Logging for a Model.
For a summary of other approaches to capture signal data, see Export Simulation Data.
To collect and use signal logging data, perform these tasks.
Mark individual signals for signal logging. See Configure a Signal for Logging.
Enable signal logging for a model. See Enable Signal Logging for a Model.
Simulate the model.
Access the signal logging data. See Access Signal Logging Data.
One approach for testing parts of a model as you develop it is to mark a superset of signals for logging. Then select different subsets of signals to log by overriding signal logging settings. You can use the Signal Logging Selector or a programmatic interface. See Override Signal Logging Settings.
Use this approach to log signals in models that use model referencing. See Models with Model Referencing: Overriding Signal Logging Settings.
With the basic signal logging workflow, you can specify additional options related to the data that signal logging collects and to how that data is displayed. You can:
Specify a name for the signal logging data for a signal. See Specify Signal-Level Logging Name.
Control how much data the simulation generates for a signal. See Limit Data Logged.
Review the signal logging configuration for a model. See View the Signal Logging Configuration.
Specify the samples for export for models with variable-step solvers. See Samples to Export for Variable-Step Solvers.
Configure the model to display signal logging data in the Simulation Data Inspector. See View Data in Simulation Data Inspector.
Signal logging in rapid accelerator mode does not log the following kinds of signals. When you update or simulate a model that contains these signals, Simulink® displays a warning that those signals are not logged.
Signals inside Stateflow® charts
Signals that use a custom data type
If you set the Configuration Parameters > Solver > Sample time constraint parameter to
Ensure sample time independent,
you cannot use signal logging in rapid accelerator mode.
Rapid accelerator mode supports signal logging, with the requirements and limitations described in Signal Logging in Rapid Accelerator Mode.
Top-model and Model block software-in-the-loop (SIL) and processor-in-the-loop (PIL) simulation modes support signal logging. For a description of limitations, see Top-Model SIL/PIL Limitations and Model Block SIL/PIL Limitations in the Embedded Coder® documentation.
Array of buses signals support signal logging, with the requirements described in Import Array of Buses Data.
You cannot log signals in For Each subsystems.
You cannot log local data in Stateflow Truth Table blocks.