Documentation

SimulinkRealTime.utils.bytes2file

Generate file for use by real-time From File block

Syntax

SimulinkRealTime.utils.bytes2file(filename, var1, . . , varX)

Description

example

SimulinkRealTime.utils.bytes2file(filename, var1, . . , varX) generates a file for use by the real-time From File block. The From File block outputs one column of variables var1, . . , varX from file filename at every time step.

Variables var1, . . , varX must be matrices in column-major format and have the same number of columns. The number of rows and the data types of the matrix elements can be different.

Data sometimes appears in row-major format (a row, not a column, refers to a time step). In such cases, transpose the variable and pass the result to SimulinkRealTime.utils.bytes2file. To optimize file writes, organize the data in columns.

Examples

collapse all

From File outputs two variables errorval and velocity at every time step from 1 to N. Each variable is in column-major format.

Variable errorval has class 'single' and dimensions [1 x N]. Variable velocity has class 'double' and dimensions [3 x N].

SimulinkRealTime.utils.bytes2file('myfile', errorval, velocity)

Configure the real-time From File block to output 28 bytes at every sample time ((1 * sizeof('single') + 3 * sizeof('double'))).

From File outputs two variables errorval and velocity at every time step from 1 to N. Each variable is in row-major format.

Variable errorval has class 'single' and dimensions [N x 1]. Variable velocity has class 'double' and dimensions [N x 3].

SimulinkRealTime.utils.bytes2file('myfile', ...
                                  transpose(errorval), ...
                                  transpose(velocity));

Configure the real-time From File block to output 28 bytes at every sample time ((1 * sizeof('single') + 3 * sizeof('double'))).

Input Arguments

collapse all

The data file contains columns of data to be output to the model.

Example: 'myfile'

Data Types: char

The X arguments each provide columns of data to be output to the model.

Example: errorval, velocity

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

See Also

Introduced in R2014a

Was this topic helpful?