Log Signals on a Hardware

You can use MAT-file logging to save signals from Simulink® models on a hardware. The signals from these models are saved as data points in MAT-files. With the data you log, you can apply fault analysis, search for transient behavior, or analyze sensor data collected over a long period of time. The data points can be saved in: Structure, Structure with time, or Array format. Simulink supports logging signals on the hardware from only these three blocks:

Without MAT-file logging on the hardware, you can only log and analyze data on the hardware through External mode or by sending the signal to a computer (using Serial, UDP, or TCP) and storing it in MATLAB®. These mechanisms need an active connection between a computer and the hardware when logging data. With MAT-file logging, you can log data without any need to connect the hardware to a computer. Other advantages of logging data to SD card over other mechanisms are:

  • The ability to collect data over a long duration for analysis.

  • The ability to store the data in a well-structured MAT-file, including timestamp information.

Before you start to save signals from Simulink models on the hardware, complete the steps listed in Prerequisites for Logging Signals.

  1. Configure Board Parameters and Enable MAT-File Logging: To save MAT-files on the hardware, the MAT-file logging option in the Configuration Parameters dialog box must be selected. Also, the hardware parameters must be specified.

  2. Configure Model to Log Signals on the Hardware: MAT-file logging is supported in models containing To Workspace, Scope, or Outport blocks. You must specify the values for several block parameters.

  3. Run Model on the Hardware: Simulink deploys code and logs signals on the hardware as MAT-files.

  4. Import MAT-Files into MATLAB: After logging is complete, you can open MAT-files in MATLAB and use them for further analysis.