Skip to content

MatlabOctaveSupport

Nicholas Corgan edited this page Sep 11, 2022 · 3 revisions

Matlab/Octave bindings for SoapySDR


If you've stumbled upon this page, this is referring to in-progress development, and the information within can change at any point before release.

See this branch.


The Matlab and Octave SoapySDR bindings use the MEX interface to provide a common API, allowing scripts to be used for both programs. The API is largely based on that of the C API, with some extensions added to provide a more familiar user experience. Overloaded functions are separated, with each function matching the corresponding C API function name.

Deviations from this policy are documented below.

Dependencies

Matlab

TODO

Octave

  • Any recent version should be fine. Development was done with Octave 5.2.0 and 7.2.0.
  • The Octave installation must include the octave-config and mkoctfile programs.

Ubuntu

sudo apt install liboctave-dev

OS X

brew install octave

Changes for Matlab/Octave API

Passing in options

TODO

Streaming

TODO

Basic example

% Enumerate devices
results = SoapySDR_Device.enumerate();
for result = results
    disp(result);
end

% Create device instance.
% Args can be user-defined or from the enumeration result. (TODO: actually support this)
sdr = SoapySDR_Device("driver", "rtlsdr");

% Query device info.
printf("Antennas:\n");
for antenna = sdr.listAntennas(SoapySDR_Direction.Rx, 0)
    printf(" * %s\n", antenna{1});
end

printf("Gains:\n");
for gain = sdr.listGains(SoapySDR_Direction.Rx, 0)
    printf(" * %s\n", gain{1});
end

printf("Frequency ranges:\n");
for freq_range in sdr.getFrequencyRange(SoapySDR_Direction.Rx, 0)
    printf(" * %s\n", freq_range{1}.disp());
end

% Apply settings.
sdr.setSampleRate(SoapySDR_Direction.Rx, 0, 1e6);
sdr.setFrequency(SoapySDR_Direction.Rx, 0. 912.3e6);

% Set up complex float stream.
rx_stream = sdr.setupStream(SoapySDR_Direction.Rx, 0, SoapySDR_StreamFormat.CF32, {0}, ...
    "bufflen", 1024, ...
    "buffers", 15);

% Receive some samples.
for i = 1:10

end

% TODO: finish

More examples

TODO

Clone this wiki locally