Main Content

Binary File Writer

Write data to binary files

  • Library:
  • DSP System Toolbox / Sinks

  • Binary File Writer block


The Binary File Writer block writes multichannel signal data to a binary file. The block specifies the name of the file and the structure of the header that precedes the signal data. If there is no header to write, the block specifies an empty structure, struct([]). The first time you write to the file, the block writes the header, followed by the data. On subsequent calls, the block writes the remaining data. If the header is empty, then no header is written.

The block writes the data in a row-major format. For example, if the input array is [1 2 4 5; 8 7 9 2], the block writes the data as [1 2 4 5 8 7 9 2].



expand all

The writer block writes the data to the file specified in the File name parameter. If the File header structure is not empty, then the writer writes the header before writing the data. The block can write floating-point data and integer data. The input data can be real or complex. When the data is complex, the block writes the data as interleaved real and imaginary components. The writer assumes the default endianness of the host machine.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Complex Number Support: Yes


expand all

Name of the file to which the block writes the data.

The structure can have an arbitrary number of fields. Each field of the structure must be a real matrix of a built-in type. For example, if File header is set to struct('field1',1:10,'field2',single(1)), the block writes a header formed by 10 double-precision values, (1:10), followed by 1 single precision value, single(1). If there is no header to write, set this parameter to an empty structure, struct([]).

  • Code generation — Simulate model using generated C code. The first time you run a simulation, Simulink® generates C code for the block. The C code is reused for subsequent simulations, as long as the model does not change. This option requires additional startup time but provides faster simulation speed than Interpreted execution.

  • Interpreted execution — Simulate model using the MATLAB®  interpreter. This option shortens startup time but has slower simulation speed than Code generation.

Block Characteristics

Data Types

double | integer | single

Direct Feedthrough


Multidimensional Signals


Variable-Size Signals


Zero-Crossing Detection


Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Introduced in R2016b