capture
Syntax
Description
[
captures IQ data of length data
,timestamp
,droppedSamples
] = capture(bba
,length
)length
from the air using the specified
baseband receiver or baseband transceiver bba
. The function returns
the captured signal data
, capture request timestamp
timestamp
, and dropped samples status
droppedSamples
.
[
captures IQ data of length pathToSavedData
,timestamp
,droppedSamples
] = capture(bbrx
,length
,SaveLocation=filepath
)length
from the air using the specified
baseband receiver bbrx
. The function returns the path to the file
where the captured signal is written pathToSavedData
, capture request
timestamp timestamp
, and dropped samples status
droppedSamples
. (since R2023b)
Examples
Configure Baseband Receiver and Capture Data
Create a baseband receiver object, specifying a radio setup configuration previously saved in the Radio Setup wizard.
bbrx = basebandReceiver("MyRadio")
bbrx = basebandReceiver with properties: RadioGain: 10 CenterFrequency: 2.4000e+09 SampleRate: 250000000 Antennas: "RF0:RX2" DroppedSamplesAction: "error" CaptureDataType: "int16"
Set the baseband sample rate and center frequency.
bbrx.SampleRate = 122.88e6; bbrx.CenterFrequency = 2.2e9;
Capture 3 ms of IQ data with the radio associated with the baseband receiver object using the default antenna.
[data,~] = capture(bbrx,milliseconds(3));
Configure Baseband Transceiver to Transmit and Capture Data
Create a baseband transceiver object, specifying a radio setup configuration previously saved in the Radio Setup wizard.
bbtrx = basebandTransceiver("MyRadio")
bbtrx = basebandTransceiver with properties: TransmitRadioGain: 10 TransmitCenterFrequency: 2.4000e+09 TransmitAntennas: "RF0:TX/RX" CaptureRadioGain: 10 CaptureCenterFrequency: 2.4000e+09 CaptureAntennas: "RF0:RX2" CaptureDataType: "int16" DroppedSamplesAction: "error" SampleRate: 250000000
Set the baseband sample rate.
bbtrx.SampleRate = 122.88e6;
Set the transmit and capture center frequencies.
bbtrx.TransmitCenterFrequency = 2.2e9; bbtrx.CaptureCenterFrequency = 2.2e9;
Generate random transmit waveform.
txWaveform = complex(randn(1000,1),randn(1000,1));
Transmit the generated waveform continuously with the radio associated with the baseband transceiver object using the default transmit antenna.
transmit(bbtrx,txWaveform,"continuous");
Capture IQ data with the radio associated with the baseband transceiver object using the default capture antenna.
[data,~] = capture(bbtrx,milliseconds(3));
Stop the continuous transmission after data capture is complete.
stopTransmission(bbtrx);
Capture Data to MAT-File with Baseband Receiver
Create a baseband receiver object, specifying a radio setup configuration previously saved in the Radio Setup wizard.
bbrx = basebandReceiver("MyRadio")
bbrx = basebandReceiver with properties: RadioGain: 10 CenterFrequency: 2.4000e+09 SampleRate: 250000000 Antennas: "RF0:RX2" DroppedSamplesAction: "error" CaptureDataType: "int16"
Capture 100 ms of IQ data and save it to a file in the basebandData folder called capture1.mat.
mkdir('basebandData'); [dataPath,~] = capture(bbrx,milliseconds(100),SaveLocation='basebandData/capture1.mat');
Load the data into the workspace.
load(dataPath,'data');
Input Arguments
bba
— Baseband application
basebandReceiver
object | basebandTransceiver
object
Baseband application, specified as a basebandReceiver
object or basebandTransceiver
object.
Note
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.
length
— Capture length
integer number of samples | duration
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 bba
or
bbrx
input and captures
ceil
(N) number of data samples.
If the baseband application is a baseband receiver, the capture
behavior depends on the capture length relative to the onboard radio buffer size.
If you specify the capture length less than the onboard radio memory buffer size, data is buffered on the radio before it is transferred to your host computer.
If you specify the capture length greater than the onboard radio memory buffer size, the onboard radio memory buffer is bypassed and data is transferred directly to your host computer. (since R2023b)
Radio Device | Memory Buffer Size | Maximum Data Samples |
---|---|---|
USRP™ N310 | 2 GB | 229 |
USRP N320 | 2 GB | 229 |
USRP N321 | 2 GB | 229 |
USRP X310 | 1 GB | 228 |
USRP X410 | 4 GB | 230 |
Note
Transmit and capture data samples on the baseband transceiver are buffered in the onboard radio memory. Therefore, if the
bba
input is a baseband transceiver, you must also take into account the length of the transmit waveform of any continuous transmission that you specify when calling thetransmit
object function.If you specify
length
greater than the radio buffer size with a baseband receiver object, the maximum data samples will be determined by the memory on your host computer.If your host computer does not have enough free memory to receive the captured data, 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
bbrx
— Baseband receiver
basebandReceiver
object
Baseband receiver, specified as a basebandReceiver
object.
Note
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.
filepath
— Path to MAT-file including file name
character vector | string scalar
Path to MAT-file including file name, specified as a character vector or string
scalar. Specify a full or relative path that contains a file name. If filepath
does
not include an extension, it appends with .mat
.
If the file does not exist, capture
creates
a Version 7.3 MAT-file. If the file already exists, capture
overwrites the file with a Version 7.3 MAT-file.
Example: 'capture1.mat'
Data Types: char
| string
Output Arguments
data
— Captured signal
complex-valued column vector | complex-valued matrix
Captured signal, returned as one of these options.
Complex-valued column vector — The vector contains data that is captured on a single capture antenna.
Complex-valued matrix — The matrix contains data that is captured on multiple capture antennas. This option applies only when
bba
is a baseband receiver orbbrx
is the input object. The number of antennas specified by theAntennas
property of thebba
orbbrx
input determines the number of matrix columns.
Use the CaptureDataType
property of the bba
or
bbrx
to specify
the data type of the returned 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].
Note
The first data samples of the captured signal can contain transient values from the radio data path.
Data Types: int16
| single
| double
Complex Number Support: Yes
timestamp
— Capture request timestamp
datetime
value
Capture request timestamp, returned as a datetime
value. The
function creates this timestamp just before requesting data capture from the
hardware.
Data Types: datetime
droppedSamples
— Status of dropped samples
1
| 0
pathToSavedData
— Path to MAT-file where capture data is saved
character vector
Path to MAT-file where capture data is saved, returned as a character vector. The full path is returned, including the file name and extension.
Example: 'H:/user/matlab/capture1.mat'
Data Types: char
Version History
Introduced in R2022aR2023b: Save captured data to a MAT-file
Calling the function with a basebandReceiver
object allows you to write captured data directly to a MAT-file.
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)