Main Content


Write baseband signals to file


A baseband file is a specific type of binary file written by the comm.BasebandFileWriter System object™. Baseband signals are typically down-converted from a nonzero center frequency to 0 Hz. The SampleRate and CenterFrequency properties are saved when the file is created.

To save a baseband signal to a file:

  1. Create a comm.BasebandFileWriter object and set the properties of the object.

  2. Call step to save a baseband signal to a file.

  3. Call release to save the baseband signal to a file and to close the file.


Alternatively, instead of using the step method to perform the operation defined by the System object, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


bbw = comm.BasebandFileWriter returns a baseband writer object, bbw, using the default properties.

bbw = comm.BasebandFileWriter(fname) returns bbw and sets fname as the Filename property.

bbw = comm.BasebandFileWriter(fname,fs) also sets fs as the SampleRate property.

bbw = comm.BasebandFileWriter(fname,fs,fc) also sets fc as the CenterFrequency property.

bbw = comm.BasebandFileWriter(fname,fs,fc,md) also sets structure md as the MetaData property.

bbw = comm.BasebandFileWriter(___,Name,Value) specifies additional properties using Name,Value pairs. Unspecified properties have default values.


bbw = comm.BasebandFileWriter('',10e6,2e9);


expand all

Name of saved file, specified as a character vector. The filename can include a relative or an absolute path.

Sample rate of the output signal, specified in Hz as a positive scalar.

Center frequency of the baseband signal, specified in Hz as a positive integer scalar or row vector. If CenterFrequency is a row vector, each element corresponds to a channel.

Data describing the baseband signal, specified as a structure. The structure can have any number of fields and any field name. The field values can be of any numeric, logical, or character data type and have any number of dimensions.

Number of samples to save, specified as a positive integer.

  • To write all the baseband signal samples to a file, set NumSamplesToWrite to Inf.

  • To write only the last NumSamplesToWrite samples to a file, set NumSamplesToWrite to a finite number.

Data Types: double


infoCharacteristic information about baseband file writer
stepWrite baseband signal to file
Common to All System Objects

Allow System object property value changes


Reset internal states of System object


collapse all

Create a baseband file writer object having a sample rate of 1 kHz and a 0 Hz center frequency.

bbw = comm.BasebandFileWriter('',1000,0);

Save today's date in the Metadata structure.

bbw.Metadata = struct('Date',date);

Generate two channels of QPSK-modulated data.

d = randi([0 3],1000,2);
x = pskmod(d,4,pi/4,'gray');

Write the baseband data to file ''.


Display information about bbw. Release the object.

ans = struct with fields:
             Filename: '/tmp/Bdoc21b_1757077_50723/tp81a94b56/comm-ex66490302/'
      SamplesPerFrame: 1000
          NumChannels: 2
             DataType: 'double'
    NumSamplesWritten: 1000


Create a baseband file reader object to read the saved data. Read the metadata from the file.

bbr = comm.BasebandFileReader('','SamplesPerFrame',100);
ans = struct with fields:
    Date: '01-Sep-2021'

Read the data from the file.

z = [];

while ~isDone(bbr)
    y = bbr();
    z = cat(1,z,y);

Display information about bbr. Release bbr.

ans = struct with fields:
    NumSamplesInData: 1000
            DataType: 'double'
      NumSamplesRead: 1000


Confirm the original modulated data, x, matches the data read from file '', z.

ans = logical


  • comm.BasebandFileWriter writes baseband signals to uncompressed binary files. To share these files, you can compress them to a zip file using the zip function. For more information, see Create and Extract from Zip Archives.

Extended Capabilities

Introduced in R2016b