5G UAV Simulation MATLAB Interfacing
5G UAV Simulation MATLAB Interfacing
Software: NetSim Standard v13.3(64 bit), Visual Studio 2022, MATLAB 2021b or higher. MATLAB,
Simulink, Robotics and System Toolbox.
Follow the instructions specified in the following link to download and setup the Project in NetSim:
https://support.tetcos.com/en/support/solutions/articles/14000128666-downloading-and-setting-up-
netsim-file-exchange-projects
Objective
Performance analysis of UAV - Base station network communications. This involves interfacing
NetSim and UAV toolbox of MATLAB.
• For Each UE in NetSim, a UAV is instantiated in MATLAB as per the UE (UAV) ID.
• MATLAB calculates the flight path and passes the Mobility information to NetSim.
• In NetSim UE movement is modelled as per MATLAB UAV co-ordinates
• Pathloss calculations done in NetSim per 38.101.
UAV Takes and moves away from gNB UAV flies in a circular pattern over the gNB
Code modifications
Upon interfacing NetSim with MATLAB the following tasks are performed during simulation start:
• MATLAB Engine process is initialized.
• MATLAB Desktop window is loaded.
• SIMULINK Model is loaded
Upon simulating a network created in NetSim the following tasks are performed periodically:
• SIMULINK Model is simulated
• SIMULINK Model is paused
• NetSim reads the data generated by SIMULINK from MATLAB workspace
• Appends the readings to the packet payload as packets are formed.
During the Simulation, the SIMULINK Model is started and paused several times for NetSim and
SIMULINK simulations to run synchronously. The X, Y and Z coordinates obtained from SIMULINK
are read from MATLAB workspace and given as input to NetSim's Mobility model. In this example,
coordinates are taken every one second and updated to the device mobility.
• NetSim Animation: Mobility of the devices configured in NetSim is given as input from
MATLAB.
• Pathloss is implemented as per 36.777 Standard.
• NetSim Plot Results: Throughput analysis as the UAV moves away from the gNB
Project: Mobility
Files:
• Mobility.c,
• Mobility.h,
• Added - UAVBasedMobility.c
• Mobility.vcxproj (Project file)
• Mobility.c
• fn_NetSim_Mobility_Init(): call to init_uav() function
• fn_NetSim_Mobility_Run(): Call to uav_run() function
• fn_NetSim_Mobility_Finish()
• Mobility.h
• MATLAB Engine variable - Used to initiate and interact with MATLAB Engine process
• Mobility.vcxproj - This is a Visual Studio project file used to load and manage the source
codes related to the Mobility in NetSim.
• path to MATLAB application
• path to MATLAB include directory.
• path to MATLAB lib directory
• information related to dependent MATLAB library files.
• UAVBasedMobility.c
• init_uav(): Initializes MATLAB, Loads SIMULINK Model, starts and pauses SIMULINK
simulation, and initializes the UAV devices in MATLAB to start simulation along with
NetSim's simulation.
Steps to simulate
1. Add the following MATLAB install directory path in the Environment PATH variable
<MATLAB_INSTALL_DIRECTORY>\bin\win64
For eg: C:\Program Files\MATLAB\R2021b\bin\win64
Note: If the machine has more than one MATLAB installed, the directory for the target platform must
be ahead of any other MATLAB directory (for instance, when compiling a 64-bit application, the
directory in the MATLAB 64-bit installation must be the first one on the PATH).
Examples
Example
Case 1: UAV Drone Takeoff - Application throughput variation with Drone mobility
• NetSim Plot: Application Throughput vs. Time