Main Content

Configure Model to Log Signals on the Android Device

MAT-file logging is supported in models containing To Workspace or Outport blocks. Specify the values for several block parameters.

To configure a Simulink® model to run on the Android® device, perform these steps:

  1. On the Simulink model toolbar, set the Simulation stop time, located to the left of Simulation mode. The Simulation stop time parameter specifies the duration for which the signals are logged in the MAT-file. After the Simulation stop time elapses, the logging of the signal stops. However, the model continues to run on the device. For example, if the Simulation stop time parameter is specified as 10.0 seconds, the logging stops after 10.0 seconds. However, the model continues to run for an indefinite time. If the Simulation stop time parameter is specified as Inf, the logging continues until the device memory is full, or you close the application.

  2. In the Simulink model, set the parameter values of To Workspace and Outport blocks.

To Workspace Block

To set the parameter values of the To Workspace block:

  1. Double-click the block, and specify these parameters in the Block Parameter dialog box.

    ParameterDescription
    Variable name

    Specify a variable name for the signal to be logged.

    Limit data points to last

    Specify the number of data points to be logged in the MAT-file. The maximum number of data points that a MAT-file can contain is 512.

    Decimation

    Use this parameter to write data points at every nth sample, where n is the decimation factor. The default decimation, 1, writes data at every time sample.

    For example, if you specify Decimation as 5, the block writes data at every fifth sample. For example, if the block sample time is 0.1 and Decimation is 5, the data points at 0, 0.5, 1, 1.5, ... seconds are logged. The data points are logged until the Simulation stop time is reached.

    Save format

    Select a format of the variable to which you save data. MAT-file logging supports only these three formats: Array, Structure with Time, or Structure.

    • Array: Save data as an array with associated time information. This format does not support variable-size data.

    • Structure with Time: Save data as a structure with associated time information.

    • Structure: Save data as a structure.

    Sample time (–1 for inherited)

    Specify an interval at which the block reads data. When you specify this parameter as –1, the sample time is inherited from the driving block.

Outport Block

To set the parameter values of the Outport block:

  1. Double-click the block, select the Signal Attributes tab, and specify the Sample time parameter. When you specify this parameter as –1, the sample time is inherited from the driving block.

  2. In the model window, open the Configuration Parameters dialog box and select Data Import/Export.

  3. Set the block parameters listed in this table:

    ParameterDescription
    Time

    Saves time data to the specified variable.

    Output

    Saves signal data to the specified variable.

    Format

    Select a format of the variable to which you save data. MAT-file logging supports only these three formats: Array, Structure with Time, or Structure.

    • Array: Save data as an array with associated time information. This format does not support variable-size data.

    • Structure with Time: Save data as a structure with associated time information.

    • Structure: Save data as a structure.

    Limit data points to last

    Specify the number of data points to be logged in a MAT-file. The maximum number of data points that a MAT-file can contain is 512.

    Decimation

    Use this parameter to write data points at every nth sample, where n is the decimation factor. The default decimation, 1, writes data at every time sample.

    For example, if you specify Decimation as 5, the block writes data at every fifth sample. For example, if the block sample time is 0.1 and Decimation is 5, the data points at 0, 0.5, 1, 1.5, ... seconds are logged. The data points are logged until the Simulation stop time is reached.