Main Content


Capture signal of interest from the air upon detection

Since R2022a



[data,timestamp,droppedSamples,status] = capture(detector,length,timeout) captures a signal of interest of length length from the air using the preamble or energy detector detector with the detection timeout timeout. The function returns the captured signal data, capture request timestamp timestamp, dropped samples status droppedSamples, and capture outcome status status.


collapse all

Define a preamble sequence with good correlation properties. For example, generate and normalize a Zadoff-Chu sequence of length 137.

seq = zadoffChuSeq(38,137);
preamble = seq/norm(seq,2); 

Create and configure a preamble detector object, specifying a radio setup configuration previously saved in the Radio Setup wizard.

pd = preambleDetector("MyRadio")
pd = 
  preambleDetector with properties:

            CenterFrequency: 2.4000e+09
                  RadioGain: 10
                   Antennas: "RF0:RX2"
                 SampleRate: 250000000
            CaptureDataType: "int16"
       DroppedSamplesAction: "error"
                   Preamble: 0
            ThresholdMethod: "adaptive"
             FixedThreshold: 0
    AdaptiveThresholdOffset: 0
      AdaptiveThresholdGain: 0
              TriggerOffset: 0

pd.SampleRate = 10.24e6;
pd.CenterFrequency = 2.2e9;
pd.CaptureDataType = "double";

Specify the preamble.

pd.Preamble = preamble; 

Set the trigger offset to a negative value to capture 500 samples before the trigger point.

pd.TriggerOffset = -500;

Capture 10 ms of data with a timeout of 1 second.

[data,timestamp,droppedSamples,status] = capture(pd,milliseconds(10),seconds(1));

Input Arguments

collapse all

Detector, specified as one of the following:


The first object function call in which you specify this object as an input requires a few extra seconds to load the application onto the hardware.

Capture length, specified as an integer number of samples or a duration value in time units. The function converts length into N samples based on the SampleRate property of the detector input and captures ceil(N) number of data samples.

Specify the capture length relative to the onboard radio memory buffer size.

Radio DeviceMemory Buffer SizeMaximum Data Samples

USRP™ N310

2 GB229


2 GB229


2 GB229


1 GB228


4 GB230


  • The onboard radio memory buffers capture and transmit data samples. Therefore, when specifying the capture length, you must also account for the length of the transmit waveform of any continuous transmission that you specify when calling the transmit object function with the detector input.

  • If your host computer does not have enough free memory to receive the captured data from the radio buffer, the function call can hang or error out. To free up memory space on your host computer, try closing other software or reduce the capture length.

Example: seconds(5)

Data Types: double | duration

Signal detection timeout on the radio, specified as a duration value in time units.


If detector is a preambleDetector object, the Preamble property specifies a periodic signal. Set the detection timeout to a value that is equal to or greater than the preamble signal period. Setting the detection timeout to a value less than the preamble signal period can end the detection operation prematurely.

Example: milliseconds(100)

Data Types: duration

Output Arguments

collapse all

Captured signal, returned as a column vector of complex values. Use the CaptureDataType property of the detector input to specify the output data type of the captured data. If you specify the return data type as single or double, the function scales the captured data sample values to the range [–1, 1].

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

Capture request timestamp, returned as a datetime value. The function creates this timestamp just before requesting data capture from the hardware.

Data Types: datetime

Status of dropped samples, returned as one of these logical values.

  • 1 — Samples are dropped during capture.

  • 0 — Samples are not dropped during capture.

Use the DroppedSamplesAction property of the detector input to specify the behavior of the capture function upon dropped samples.

Data Types: logical

Capture outcome status, returned as one of these logical values.

  • 1 — Capture operation was successful and the captured signal of interest is returned in data.

  • 0 — Detect and capture operation timed out.

Data Types: logical

Version History

Introduced in R2022a

expand all