Main Content

capture

Capture RF signal data using RTL-SDR radio

Since R2023b

Add-On Required: This feature requires the Communications Toolbox Support Package for RTL-SDR Radio add-on.

Description

[data,metadata] = capture(rx,length) captures ceil(length) continuous data samples using the RTL-SDR radio hardware associated with the rx receiver System object™. The function returns the captured data samples in the output data. The function also returns capture-time configuration settings for the radio device in the output metadata.

[data,metadata] = capture(rx,length,unit) specifies the unit value for the capture length. The function converts length units into N samples and returns ceil(N) samples.

[data,metadata] = capture(___,Filename=filename) specifies filename, a filename for the captured data, in addition to inputs from any of the previous syntaxes. The function saves the captured data and metadata to a baseband file reader file named filename.

example

Examples

collapse all

Use the capture function and an RTL-SDR radio to capture FM signals.

Configure RTL-SDR Hardware

To configure your radio hardware for host-radio communication, see RTL-SDR Support Package Hardware Setup.

Configure Receiver System Object

Create a receiver System object and set the center frequency to the frequency of a local FM station.

centerFrequency = 93.5e6;
sampleRate = 2.4e6;
rx = comm.SDRRTLReceiver('0',CenterFrequency = centerFrequency,...
    SampleRate = sampleRate,OutputDataType = 'double');

Initiate Data Capture

Call the capture function by specifying the receiver object and a capture duration. The function returns the captured data in data and the configuration settings in the structure metadata. After capturing the FM signal, unlock the receiver object by using the release function.

[data,metadata] = capture(rx,5,'Seconds');
release(rx);

Use the spectrumAnalyzer System object to visualize the received FM signal.

scope = spectrumAnalyzer(SampleRate=sampleRate);
scope(data);
release(scope);

rtl_capture.png

Input Arguments

collapse all

Receiver, specified as a comm.SDRRTLReceiver System object. The function uses this object to communicate with the RTL-SDR radio connected to the host computer.

Capture duration, specified as a positive scalar. Specify the unit of capture duration as samples or seconds in the unit argument. The maximum number of samples you can capture is 256e6.

Note

If the number of samples to capture is greater than 3.75e5, the RTL-SDR radio captures 3.75e5 samples per frame until it captures the specified number of samples.

Data Types: double

Capture duration unit, specified as one of these values:

  • "Samples" — The function returns ceil(length) samples.

  • "Seconds" — The function converts length seconds into N samples based on the BasebandSampleRate property of the input receiver rx. The function returns ceil(N) samples.

Filename for saving captured data and metadata, specified as a character vector or string scalar. When you specify this input, the function saves the captured data and metadata to a baseband file. To read this file, use the comm.BasebandFileReader System object. The saved file has the .bb extension.

Example: "rxdata" or "rxdata.bb" configures the function to save data to a file with the name rxdata and the .bb extension.

Data Types: char | string

Output Arguments

collapse all

Output signal received from the radio hardware, returned as a complex-valued column vector.

The output signal supports complex values with these data types:

  • 16-bit signed integers — Complex values are the raw 16-bit in-phase (I) and quadrature phase (Q) samples from the RTL-SDR radio.

  • Single-precision floating point — Scaled complex values in the range [–1, 1].

  • Double-precision floating point — Scaled complex values in the range [–1, 1].

To specify the base data type, use the OutputDataType property of the input receiver rx.

Data Types: int16 | single | double
Complex Number Support: Yes

Capture-time configuration settings for the RTL-SDR device, returned as a structure that contains these fields:

FieldDescription
Date

Date and time of the data capture.

BasebandSampleRate

Baseband sampling rate, in Hz, configured in the RTL-SDR device.

CenterFrequency

Center frequency, in Hz, configured in the RTL-SDR device.

DeviceName

Name of the RTL-SDR device.

CaptureLengthSamples

Capture length in samples.

CaptureLengthSeconds

Capture length in seconds.

SDRRReceiverConfiguration

List of property values and settings that describe the System object state.

TunerAGC

Status of EnableTunerAGC property configured in the RTL-SDR device.

Gain

Tuner gain, in dB, configured in the RTL-SDR device when EnableTunerAGC is enabled.

Data Types: struct

Version History

Introduced in R2023b