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:
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 asInf
, the logging continues until the device memory is full, or you close the application.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:
Double-click the block, and specify these parameters in the Block Parameter dialog box.
Parameter Description 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 is0.1
and Decimation is5
, 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
, orStructure
.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:
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.In the model window, open the Configuration Parameters dialog box and select Data Import/Export.
Set the block parameters listed in this table:
Parameter Description 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
, orStructure
.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 is0.1
and Decimation is5
, 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.