Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

comm.BasebandFileWriter System object

Write baseband signals to file

Description

A baseband file is 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.

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.

Note

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.

Construction

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.

Example:

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

Properties

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

Methods

infoCharacteristic information about baseband file writer
resetReset states of baseband file writer object
stepWrite baseband signal to file
Common to All System Objects
clone

Create System object with same property values

getNumInputs

Expected number of inputs to a System object

getNumOutputs

Expected number of outputs of a System object

isLocked

Check locked states of a System object (logical)

release

Allow System object property value changes

Examples

expand all

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

bbw = comm.BasebandFileWriter('baseband_data.bb',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 'baseband_data.bb'.

bbw(x)

Display information about bbw. Release the object.

info(bbw)
release(bbw)
ans = 

  struct with fields:

             Filename: '/tmp/Bdoc17b_705616_27597/publish_examples12/tp31e43069/ex66490302/baseband_data.bb'
      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('baseband_data.bb','SamplesPerFrame',100);
bbr.Metadata
ans = 

  struct with fields:

    Date: '01-Sep-2017'

Read the data from the file.

z = [];

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

Display information about bbr. Release bbr.

info(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 'baseband_data.bb', z.

isequal(x,z)
ans =

  logical

   1

Tips

  • 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 (MATLAB).

Extended Capabilities

Introduced in R2016b

Was this topic helpful?