Main Content

Create Standalone Application from Wireless Testbench Code

R2026b
Since R2026b

You can use MATLAB® Compiler™ to package Wireless Testbench™ code as a standalone application that you can run on systems without MATLAB. The target system requires only MATLAB Runtime.

Supported platforms: Windows®, Linux®, macOS

Note

The application is not cross-platform, and the executable type depends on the operating system on which you generate it.

Requirements

  • Use a supported NI™ USRP™ radio. For more information about radio support, see Supported Radio Devices.

  • Install Wireless Testbench Support Package for NI USRP Radios. For installation instructions, see Install Support Package for NI USRP Radios.

  • Install MATLAB Compiler.

  • Install any other MathWorks® products required by your application.

Set Up Radio

The standalone application bundles the UHD™ driver version from the MATLAB release used to compile the application. To ensure each radio you plan to use is set up with a compatible driver version, run the Radio Setup wizard on the compilation host, or any host with the same MATLAB version.

The default radio IP address depends on the SFP+ port. Because the standalone application uses the IP address from the radio setup configuration at compile time, use the same type of network interface during compilation that you plan to use on the target host computer. For example, if you plan to use a 1 Gigabit Ethernet network interface on the target host computer, use a 1 Gigabit Ethernet network interface when you compile the application.

Prepare Wireless Testbench Code for MATLAB Compiler

You can compile a MATLAB function, class, or app saved as one of these file types: .m, .p, .mlx, .mlapp, or .mex.

Most Wireless Testbench objects require a radio setup configuration in the compiled application. This table details the supported objects and their prerequisites.

Wireless Testbench ApplicationAvailable ObjectsPrerequisites
Radio ManagementRadio objects (constructed using the radioConfigurations function)Radio setup configuration
Phase CalibrationbasebandPhaseAnalyzerRadio setup configuration
Transmit and CapturebasebandReceiver, basebandTransceiver, basebandTransmitterRadio setup configuration
Spectrum MonitoringpreambleDetector, energyDetectorRadio setup configuration
Live I/Ocomm.SDRuReceiver, comm.SDRuTransmitterN/A
FPGA Targeting*usrp, fpga

Radio setup configuration and generated files

* The compiled application supports running applications that use previously generated bitstreams. The compiled application does not support generating bitstreams.

To prepare your code for compilation:

  1. If your application requires a radio setup configuration, ensure the configuration exists on the MATLAB instance you use for compilation. To create a radio setup configuration, use the Radio Setup wizard. If the radio setup configuration is missing, compilation succeeds but the application fails at runtime.

    Note

    The standalone application uses the IP address stored in the radio setup configuration at compile time. The IPAddress property is read-only in the compiled application.

  2. Write a MATLAB function that uses one of the supported objects listed in the preceding table. Your code must be in a finished state and ready for the end user to run.

    For example, this function captures 0.5 seconds of data from a USRP radio using a basebandReceiver object. Save the function as a MAT file named captureFromRadio.m.

    function data = captureFromRadio()
    bbrx = basebandReceiver("MyRadio");
    bbrx.SampleRate = 25e6;
    bbrx.CenterFrequency = 2.2e9;
    [data,~] = capture(bbrx,seconds(0.5));
    end
  3. If your application uses the Target NI USRP Radios Workflow, prepare the additional files required for compilation.

    Ensure any files required to run the compiled application are present in the compilation folder, including:

Create Standalone Application

After you prepare your code, create a standalone application by using either of these approaches:

Include Additional Files

The bitstream file, DTS file, and hand-off information file are not detected automatically by the dependency analysis and must be included manually. Include these files in the deployable archive using one of these options.

  • In the programmatic workflow, use the AdditionalFiles (MATLAB Compiler) name-value argument.

    buildResults = compiler.build.standaloneApplication("captureFromRadio.m", ...
        AdditionalFiles=["myBitstream.bit","myDeviceTreeSource.dts","myModel_wthandoffinfo.mat"]);

  • In the Standalone Application Compiler app, add these files in theFiles Required for Standalone to Run > Custom Requirements section of the compiler task.

Verify Standalone Application

To verify your standalone application, install and run the application on the compilation host before you deploy it to the target system. For details, see Install Deployed Application (MATLAB Compiler).

Set Up Target System

Configure Network and Connect Radio

To set up the target host computer to connect to the radio:

Install and Run Deployed Application

To install and run the deployed application on the target system, follow the steps in Install Deployed Application (MATLAB Compiler).

See Also

Functions

Tools

Apps

Topics