Main Content

comm.BasebandFileWriter

Write baseband signal to file

Description

Thecomm.BasebandFileWriterSystem object™ writes a specific type of binary file to store baseband signal data. Baseband signals are typically down-converted from a nonzero center frequency to 0 Hz. TheSampleRateandCenterFrequencyproperties are saved when the file is created.

To write a baseband signal to a file:

  1. Create thecomm.BasebandFileWriterobject and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, seeWhat Are System Objects?

Creation

Description

bbw= comm.BasebandFileWritercreates a baseband file writer System object to write a baseband signal to a specific type of binary file.

bbw= comm.BasebandFileWriter(fname)sets theFilenameproperty tofname.

bbw= comm.BasebandFileWriter(fname,fs)also sets theSampleRateproperty tofs.

bbw= comm.BasebandFileWriter(fname,fs,fc)also sets theCenterFrequencyproperty tofc.

example

bbw= comm.BasebandFileWriter(fname,fs,fc,md)also sets theMetadataproperty tomd.

bbw= comm.BasebandFileWriter(___,Name=Value)sets properties using one or more name-value arguments in addition to an input argument combination from any of the previous syntaxes. For example,SampleRate=2sets the sample rate of the baseband file writer to 2.

Properties

expand all

Unless otherwise indicated, properties arenontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and thereleasefunction unlocks them.

If a property istunable, you can change its value at any time.

For more information on changing property values, seeSystem Design in MATLAB Using System Objects.

Name of the baseband file to write, specified as a string scalar or character vector. The filename can include a relative or absolute path.

Data Types:string|char

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

Data Types:double

Center frequency of the baseband signal in Hz, specified as a positive scalar or row vector. When this property is a row vector, each element is the center frequency of a channel in a multichannel signal.

Data Types:double

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.

Data Types:struct

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

  • To write all of the baseband signal samples to a file, set this property toInf.

  • To write only the lastNumSamplesToWritesamples to a file, set this property to a positive integer.

Data Types:double

Usage

Syntax

Description

bbw(samples)writes one frame of baseband samples to the file specified by theFilenameproperty. The number of samples written to the file is determined by theNumSamplesToWriteproperty.

Input Arguments

expand all

Baseband signal to write to the file, specified as anNsample-by-Nchannelmatrix of numeric values.Nsampleis the number of baseband samples andNchannelis the number of channels in the input signal. IfNumSamplesToWriteisInf, the object writes all of the samples in the input signal to the file.

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

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object namedobj, use this syntax:

release(obj)

expand all

info Characteristic information about baseband file writer
step RunSystem objectalgorithm
release Release resources and allow changes toSystem objectproperty values and input characteristics
reset Reset internal states ofSystem object

Examples

全部折叠

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

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

Save the date for today in theMetadatastructure.

bbw。元数据=结构('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 filebaseband_data.bb.

bbw(x)

Display information about the baseband file writer. Then, release the object.

info(bbw)
ans =struct with fields:Filename: '/tmp/Bdoc22a_1891349_59546/tpee747ad5/comm-ex66490302/baseband_data.bb' SamplesPerFrame: 1000 NumChannels: 2 DataType: 'double' NumSamplesWritten: 1000
release(bbw)

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

bbr = comm.BasebandFileReader('baseband_data.bb',...'SamplesPerFrame',100); bbr.Metadata
ans =struct with fields:Date: '26-Feb-2022'

Read the data from the file.

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

Display information about the baseband file reader. Then, release object.

info(bbr)
ans =struct with fields:NumSamplesInData: 1000 DataType: 'double' NumSamplesRead: 1000
release(bbr)

Confirm that the original modulated datax, matches the dataz, read from filebaseband_data.bb.

isequal(x,z)
ans =logical1

Tips

  • comm.BasebandFileWriterwrites baseband signals to uncompressed binary files. To share these files, you can compress them to a zip file using thezipfunction. For more information, seeCreate and Extract from Zip Archives.

Extended Capabilities

版本历史

Introduced in R2016b