Create Standalone Application for USRP Radios Using Standalone Application Complier App
You can create MATLAB® code that configures your NI™
USRP™ radio as a transmitter or receiver by using a comm.SDRuTransmitter
or comm.SDRuReceiver
System object™ and deploy it as a standalone application using Standalone
Application Complier app that you can share with other users. A
standalone application can be designed using Standalone Application Complier app
or it can be a command-line executable. The target system running a standalone application
requires a MATLAB Runtime installation to run the application. It does not require a licensed copy of
MATLAB. For more information, see Download and Install MATLAB Runtime (MATLAB Compiler).
Requirements
A supported NI USRP radio. For more information, see Supported Radio Devices.
Wireless Testbench™ Support Package for NI USRP Radios
MATLAB Compiler™
Create MATLAB Function Using USRP System Object
Write a MATLAB function to capture data using a USRP radio. Your code must be in a finished state and ready for the end user to run. For more information, see Write Deployable MATLAB Code (MATLAB Compiler).
rx = comm.SDRuReceiver(Platform='X310',IPAddress='192.168.10.2'); rx.MasterClockRate = 184.32e6; rx.CenterFrequency = 2.4e9; [data,~] = capture(rx,5,'Seconds'); release(rx);
Save the function in a file named
usrpReceive.m
.
Create Compiler Task
On the Apps tab in the MATLAB toolstrip, under Application Deployment, click Standalone Application Complier. Alternatively, you can open the Application Compiler app by entering
applicationCompiler
in the MATLAB command window.Add a compiler task to a new MATLAB project. Select Start a new project and create a compiler task and create a new project
USRPReceiveProject
in your working folder. You can also browse for an existing MATLAB project and add a compiler task.A new compiler task named
StandaloneDesktopApp1
opens in the Editor. In the Main File section of the compiler task, click Add Main File and selectusrpReceive.m
.
Specify Build Options
In the Application Info section, replace the string
My Desktop Application
with the name for your standalone application,USRP Receive
. You can specify other details in this section, such as the author, company, and description.In the Executable Details section, name the executable
usrpReceive
. Under Application Type, select Standalone Windows Application if you are using Windows®; otherwise, select Standalone Application.To obfuscate the MATLAB code, select Obfuscate all file names, folder structures, code, and data in build output.
You can also add a splash screen or icon.
In the Installer Details section, specify the Package Type as Fetch MATLAB Runtime form mathworks.com during application installation and name the generated installer as
usrpReceiveInstaller
.
Package Standalone Application
To generate both the standalone application and an installer, click Build and Package. To create the application executable without an installer, click Build and Package > Build.
The compiler generates files in the
<compiler_task_name>/output
folder in your project folder. The build subfolder contains the standalone application executable, and the package subfolder contains an installer for your standalone application along with MATLAB Runtime. To choose a different output location for the generated files, update the paths in the Output Locations section.Click Open Output Folder to open the folder containing the standalone application executable.
Test Standalone Application
To test the application in MATLAB before deployment, connect your radio to your host machine. Use the Radio Setup wizard to set up your radio.
Run the executable in the MATLAB Command Window using the bang operator.
!D:\Work\USRPReceiveProject\StandaloneDesktopApp1\output\build\usrpReceive.exe
Deploy Standalone Application
To deploy your application outside of MATLAB, you must have MATLAB Runtime installed at the same version as the MATLAB version used to build the application. Make sure that your end users can run the application by including MATLAB Runtime in the installer or by supplying users with information on how to download it. For information on installing and using MATLAB Runtime, see About MATLAB Runtime (MATLAB Compiler).
For more information on deployment, see Steps for Deployment with MATLAB Compiler (MATLAB Compiler).
Install Deployed Application
For Windows and macOS platforms, double click the executable file
usrpReceive.exe
.For Linux® platforms, open a terminal and type:
sudo -H ./MyAppInstaller.install
To connect to the Internet using a proxy server, click Connection Settings. Enter the proxy server settings in the provided window and click OK. Click Next.
Choose the installation folder for the application. To create a desktop shortcut, check the box labeled Add a shortcut to the desktop. Click Next.
If MATLAB Runtime is not already installed on your machine, choose the installation folder for the MATLAB Runtime libraries and click Next.
Select Yes to accept the terms of the MATLAB Runtime license agreement and click Next.
Click Install to begin the installation.
On Linux and macOS platforms, after copying files to your disk, the installer displays the Product Configuration Notes dialog box. This dialog box contains information necessary for setting your path environment variables. Copy the path information from this dialog box, save it to a text file, and then click Next. For information on setting environment variables, see Set MATLAB Runtime Path for Deployment (MATLAB Compiler).
Click Finish to exit the installer.
See Also
Standalone Application Compiler (MATLAB Compiler)
Topics
- Download and Install MATLAB Runtime (MATLAB Compiler)