How-to
MATLAB
In MATLAB the vortarian MEX file receives both links on its own threads, aligns them by the datagram headers and returns a contiguous block of all four channels as an int16 matrix.
Requirements
| Item | Value |
|---|---|
| Host | Linux x86-64 (the MEX file uses recvmmsg) |
| MATLAB | tested with R2026b Update 1 on Ubuntu 26.04; no toolbox |
| Binary | vortarian.mexa64: vortarian-octave releases |
| Example scripts | host-tools/matlab |
| Host settings | Host setup |
Put the MEX file in one folder with the scripts and add the folder to the path:
addpath('~/host-tools/matlab');
vortarian('version')
Calls
| Call | Function |
|---|---|
vortarian('version') | Version of the MEX file. |
vortarian('config', 'host', '192.168.67.2') | Sets the defaults for the following calls. |
txt = vortarian('cmd', 'adc 1 nco 375000000') | Sends a command, or a cell array of commands, and returns the answer. Commands: Board control. |
[iq, info] = vortarian('rx', N) | Captures N contiguous samples per channel from the running streams. |
[iq, info] = vortarian('rx', N, ...) | The same with the options below. |
Option of 'rx' | Meaning |
|---|---|
'on', 'debug on' | Command sent before the capture: starts the streams. |
'off', 'debug off' | Command sent after the capture: stops the streams. |
'ports', 10700 | One link only: iq has four columns. |
'margin', M | Datagrams kept per link while waiting for the other link; default 8192 (67 MB per link). |
Returned data
Column of iq | Content |
|---|---|
| 1, 2 | I, Q of RX A |
| 3, 4 | I, Q of RX B |
| 5, 6 | I, Q of RX C |
| 7, 8 | I, Q of RX D |
- int16; full scale 32768.
- Row k is the same sampling instant in all four channels.
- The block is always contiguous. When a datagram is lost, the block restarts after the gap.
inforeports the datagrams lost before the block was complete.
Conversion to complex samples of all four channels:
x = complex(double(iq(:, 1:2:end)), double(iq(:, 2:2:end))) / 32768;
Memory
| Quantity | Size |
|---|---|
| 1 s of all four channels, as datagrams | 1 GB per link |
| 1 s of all four channels, complex double | 8 GB |
| Socket buffer requested per link | 256 MB |
Process long records in parts.
Timing
- The capture start is a software event: its timing against the outside world varies by milliseconds.
- Within a block, the samples are spaced exactly 1/fs = 8 ns.
- Each
vortarian('rx', N)call opens the sockets, takes the next N contiguous samples and closes the sockets; the datagrams between two calls are not received. - When the sockets open, one link can start about 1 ms after the other. With repeated calls on running streams use
'margin', 1024. - A call for 262 144 samples (2.1 ms) takes about 10 to 15 ms on the test host.
Minimal capture
vortarian('config', 'host', '192.168.67.2');
vortarian('cmd', 'init'); % once after power-up
vortarian('cmd', {'adc 1 nco 375000000', 'adc 2 nco 375000000'});
iq = vortarian('rx', 2^21, 'on', 'debug on', 'off', 'debug off');
x = complex(double(iq(:, 1:2:end)), double(iq(:, 2:2:end))) / 32768;
Example scripts
| Script | Function |
|---|---|
vortarian_spectrogram.m | Spectrogram of one channel: 221 samples (16.8 ms), 1024-point Hann FFT, dBFS, IF and RF axes. |
vortarian_spectrogram_4ch.m | Spectrograms of all four channels from one capture, common colour scale. |
vortarian_waterfall.m | Live spectra and waterfalls of four channels. Each row is the peak or the mean power of 256 contiguous spectra, 2.1 ms. |
optimize_eth_config.sh | Host interface settings. |
The spectrogram scripts are the same files as for GNU Octave; only the default colour map differs. Scaling of the spectra: Spectrum scaling.
vortarian_spectrogram_4ch.m in MATLAB with the 4R2C-2G5 front-end (2450 MHz at IF 375 MHz), RF gain 20 dB, antennas on RX A and RX B, none on RX C and RX D. Wi-Fi frames of several transmitters between 2400 and 2470 MHz, with different levels on the two antennas; periodic bursts from 2450 MHz upwards. The colour scale runs from 10 dB below the median to the maximum of the capture, here −104.6 to −45.8 dBFS.
vortarian_waterfall.m with det = 'mean' after 400 rows, about 37 s; antennas on RX A and RX B. Each row is the mean power of 2.1 ms. Wi-Fi frames between 2400 and 2470 MHz, Bluetooth Low Energy advertising on 2402, 2426 and 2480 MHz, a pulsed carrier at 2450.5 MHz with the frequency sweep of its switch-off up to 2485 MHz.
Signal in the time domain
A narrow-band signal is taken out of the capture by mixing it to 0 Hz, filtering and decimating. With x from the minimal capture (NCO 375 MHz at RF 2450 MHz), the Bluetooth Low Energy advertising channel on 2402 MHz of RX A:
fs = 125e6; D = 5;
n = (0:size(x, 1) - 1)';
y = x(:, 1) .* exp(-2i * pi * (2402e6 - 2450e6) / fs * n); % 2402 MHz to 0 Hz
h = conv(ones(50, 1), ones(50, 1)); % low-pass, about 2 MHz wide
y = filter(h / sum(h), 1, y); y = y(1:D:end); % 25 MS/s
level = 20 * log10(abs(y) + 1e-9); % envelope [dBFS]
f = angle(y(2:end) .* conj(y(1:end-1))) * (fs / D) / (2 * pi); % instantaneous frequency [Hz]
The filter is two moving averages of 50 samples in series; it needs no toolbox or package.
One advertising packet, antenna on RX A, RF gain 20 dB, drawn in MATLAB. Top: envelope, −29.3 dBFS; the transmitter is on for about 400 µs. Middle: I and Q of the first 44 µs. Bottom: instantaneous frequency, GFSK at 1 Mbit/s with about ±230 kHz deviation; the 8 preamble bits and the 32 bits of the advertising access address 0x8E89BED6 can be read directly. The bit labels were added for the figure.
A detail of a pulsed signal, with a zoomed spectrogram: Python.
Live display
vortarian_waterfall runs until the figure is closed; vortarian_waterfall(n) stops after n rows. It switches the streams on once and sends debug off when it returns, also after Ctrl+C.
| Parameter in the script | Default | Meaning |
|---|---|---|
f_nco | 375e6 | NCO frequency of both ADCs |
f_rf | 2450e6 | RF frequency at the IF centre |
nfft | 1024 | FFT length, 122 kHz per bin |
K | 256 | spectra per row: 2.1 ms |
det | ’peak’ | row detector: 'peak' or 'mean' power of the K spectra |
rows | 400 | rows of each waterfall |
lim | [-105 -40] | colour scale and spectrum range, dBFS |
Live display: coverage
| Display | Contiguous samples per row | Share of the signal |
|---|---|---|
| GNU Radio QT GUI waterfall, update period 0.1 s | 1024 (8.19 µs) | 0.008 % |
vortarian_waterfall.m, K = 256, about 85 ms per row | 262 144 (2.1 ms) | 2.5 % |
Row detector:
det | Noise floor | A burst shorter than the row | A carrier that sweeps |
|---|---|---|---|
'peak' | about 11 dB above that of a single spectrum | shown at its full level | fills every bin it crosses at nearly its full level |
'mean' | that of a single spectrum | reduced by the ratio of its length to 2.1 ms | reduced by the time it spends in a bin |
Example, the pulsed carrier of the figure above: on for about 100 µs about every 510 µs at −46 dBFS, then its frequency runs up by 27 MHz in about 30 µs while the level falls by 10 dB. With 'peak' the sweep is a band at about −65 dBFS from 2451 to 2485 MHz in every row; with 'mean' the same band lies at −80 to −90 dBFS and the carrier at −55 dBFS. The sweep resolved in time: Python.
Error messages
| Message | Cause |
|---|---|
vortarian:busy | Another client holds the control port: board console, a second MATLAB session, GNU Radio. |
vortarian:board | The board answered with an error, for example “Board initialization has not been run”: init has not run since power-up. |
vortarian:nodata, timeout | No datagrams arrive: links, host addresses, firewall for UDP 10700 and 10701. |
no ... contiguous packets present in all streams | Datagrams lost on the host: MTU, ring size, pause frames, net.core.rmem_max; or raise 'margin'. |
| The display updates slowly | MATLAB draws without graphics acceleration: fewer rows, a smaller figure, or a larger K. |