Create Standalone Application from Wireless Testbench Code
R2026bYou 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 Application | Available Objects | Prerequisites |
|---|---|---|
| Radio Management | Radio objects (constructed using the radioConfigurations function) | Radio setup configuration |
| Phase Calibration | basebandPhaseAnalyzer | Radio setup configuration |
| Transmit and Capture | basebandReceiver, basebandTransceiver, basebandTransmitter | Radio setup configuration |
| Spectrum Monitoring | preambleDetector, energyDetector | Radio setup configuration |
| Live I/O | comm.SDRuReceiver, comm.SDRuTransmitter | N/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:
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
IPAddressproperty is read-only in the compiled application.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
basebandReceiverobject. Save the function as a MAT file namedcaptureFromRadio.m.function data = captureFromRadio() bbrx = basebandReceiver("MyRadio"); bbrx.SampleRate = 25e6; bbrx.CenterFrequency = 2.2e9; [data,~] = capture(bbrx,seconds(0.5)); end
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:
Helper functions.
The setup function file generated in the Generate Host Interface Scripts step of the workflow.
The bitstream file, device tree source (DTS) file, and hand-off information file (
) generated in the Generate Bitstream and Program FPGA step of the workflow.modelname_wthandoffinfo.matNote
These files are not detected automatically by the dependency analysis and must be included manually. For details, see Include Additional Files.
Create Standalone Application
After you prepare your code, create a standalone application by using either of these approaches:
Programmatic — Use the
compiler.build.standaloneApplication(MATLAB Compiler) function. For detailed steps, see Create Standalone Application from MATLAB (MATLAB Compiler).Interactive — Use the Standalone Application Compiler (MATLAB Compiler) app. For detailed steps, see Create Standalone Application Using Standalone Application Compiler App (MATLAB Compiler).
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:
Configure the network interface on the target host computer with a static IP address. You must use the IP address stored in the radio setup configuration.
Configure your network adapter settings. For details, see:
Connect the radio to the target host computer. For details, see Connect Radio to Host Computer.
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
radioConfigurations|compiler.build.standaloneApplication(MATLAB Compiler)
Tools
Apps
- Standalone Application Compiler (MATLAB Compiler)
Topics
- Install Support Package for NI USRP Radios
- Supported Radio Devices
- Create Standalone Application from MATLAB (MATLAB Compiler)
- Create Standalone Application Using Standalone Application Compiler App (MATLAB Compiler)
- Install Deployed Application (MATLAB Compiler)