Read baseband signals from file


The comm.BasebandFileReader object reads a baseband signal from a specific type of binary file written by comm.BasebandFileWriter. Baseband signals are typically downconverted from a nonzero center frequency to 0 Hz. The SampleRate and CenterFrequency properties are saved when the file is created. The comm.BasebandFileReader object automatically reads the sample rate, center frequency, number of channels, and any descriptive data and saves them to its read-only properties.

To create an input signal from a saved baseband file:

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

  2. Call step to generate a baseband signal from saved data.

  3. Call release 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) and y = obj() perform equivalent operations.


bbr = comm.BasebandFileReader returns a baseband reader object, bbr, using the default properties.

bbr = comm.BasebandFileReader(fname) returns a baseband reader object and sets fname as the Filename property.

bbr = comm.BasebandFileReader(fname,spf) also sets spf as the SamplesPerFrame property.

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


bbr = comm.BasebandFileReader('recorded_data',100);


expand all

Name of the baseband file to read, specified as a character vector. Specify the absolute path only if the file is not on the MATLAB® path. Only the absolute path is saved and displayed.

This property is read-only.

Sample rate of the saved baseband signal in Hz.

This property is read-only.

Center frequency of the saved baseband signal in Hz. When this property is a row vector, each element represents the center frequency of a channel in a multichannel signal.

This property is read-only.

Number of channels of the saved baseband signal.

This property is read-only.

Data describing the baseband signal. If the file has no descriptive data, this property is an empty structure.

Number of samples per output frame, specified as a positive integer.

Data Types: double

Flag to repeatedly read baseband file, specified as a logical scalar. To repeatedly read the baseband file specified by Filename, set this property to true.


infoCharacteristic information about baseband file reader
Common to All System Objects

Allow System object property value changes


Generate baseband signal from file


Reset states of baseband file reader object


Read status of baseband file samples


expand all

Create a baseband file reader object.

bbr = comm.BasebandFileReader
bbr = 
  comm.BasebandFileReader with properties:

            Filename: '/mathworks/devel/bat/Bdoc19b/build/matlab/toolbox/comm/comm/'
          SampleRate: 1
     CenterFrequency: 100000000
         NumChannels: 1
            Metadata: [1x1 struct]
     SamplesPerFrame: 100
    CyclicRepetition: false

Use the info method to gain additional information about bbr. The file contains 10000 samples of type 'double'. No samples have been read.

ans = struct with fields:
    NumSamplesInData: 10000
            DataType: 'double'
      NumSamplesRead: 0

Read the entire contents of the file by using the isDone method to terminate the loop.

y = [];

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

Plot the absolute magnitude of the baseband data.


Confirm that all the samples have been read.

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

The total number of samples and the number of samples read are the same.

Release the baseband file reader resources.


Extended Capabilities

Introduced in R2016b