addMobility
Description
addMobility( adds a default
mobility model (random waypoint) to one or more new radio (NR) user equipment (UE) nodes,
ue)ue. In the random waypoint model, a wireless node pauses for some
duration at a location before moving towards its next random destination (waypoint) with a
random speed. The node repeats this process at each waypoint. This feature also requires the
Wireless Network
Toolbox™ product.
addMobility(
sets the mobility configuration parameters using one or more optional name-value arguments.
For example, ue,Name=Value)PauseDuration=0.02 sets the pause duration of a UE node to
0.02 seconds. If you add the mobility model to multiple wireless nodes in a single
addMobility function call, all the nodes use the mobility parameter
values specified by the name-value arguments.
Examples
Initialize wireless network simulator.
networkSimulator = wirelessNetworkSimulator.init;
Create a gNB node with these specifications.
Duplex mode — Time division duplex
Channel bandwidth — 20 MHz
Subcarrier spacing — 30 KHz
gnb = nrGNB(ChannelBandwidth=20e6,DuplexMode="TDD",SubcarrierSpacing=30e3);Create a UE node with a transmit power of 20 dBm.
ue = nrUE(TransmitPower=20);
Add a random way point mobility model to the UE node.
addMobility(ue,BoundaryShape="rectangle")Establish a connection between the UE and gNB nodes.
connectUE(gnb,ue)
Create a voice over Internet protocol (VoIP) application traffic pattern object.
traffic = networkTrafficVoIP;
Add the data traffic source to the gNB node. Set the destination node as the UE node.
addTrafficSource(gnb,traffic,DestinationNode=ue)
Add the gNB node to the wireless network simulator.
addNodes(networkSimulator,gnb)
Add the UE node to the wireless network simulator.
addNodes(networkSimulator,ue)
Specify the simulation time, in seconds.
simulationTime = 0.3;
Run the simulation for the specified simulation time.
run(networkSimulator,simulationTime)
Obtain the statistics for the gNB and UE nodes.
gnbStats = statistics(gnb); ueStats = statistics(ue);
Input Arguments
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: addMobility(ue,PauseDuration=0.02) sets the pause duration
for a UE node, after it reaches a target waypoint, to 0.02 seconds.
Since R2026a
Mobility model, specified as "random-waypoint",
"random-walk", "constant-velocity", or an
object of a subclass of wnet.Mobility. When you provide a custom
mobility object, the function generates a copy of the mobility model object and
associates it with the node. Consequently, after the function assigns the mobility
model to the node, changes you make to the original mobility model object do not
affect the node.
If you specify a custom mobility model object, the function ignores any other mobility parameters provided as name-value arguments.
Speed range, specified as a two-element positive vector. The function sets the speed of the UE node according to a continuous uniform distribution based on this range. The first element of the vector specifies the minimum speed of the node, while the second specifies the maximum speed, in meters per second.
To set the speed to a constant value, specify SpeedRange as a
two-element row vector with identical values.
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-waypoint" or "random-walk".
Data Types: double
Pause duration of the UE node after reaching a target waypoint, specified as a nonnegative scalar. Units are in seconds.
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-waypoint".
Data Types: double
Shape of the node mobility area, specified as "rectangle" or
"circle".
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-waypoint" or "random-walk".
Data Types: char | string
Center coordinates and dimensions of the mobility area, specified as a
three-element or four-element numeric vector, depending on the value of the
BoundaryShape argument. Units are in meters.
"rectangle"— Specify a four-element numeric vector of the form [xcenter ycenter length width]. The default value is [xcurrent ycurrent1010], where the first two elements specify the xy-coordinates of current node position."circle"— Specify a three-element numeric vector of the form [xcenter ycenter radius]. The default value is [xcurrent ycurrent10], where the first two elements specify the xy-coordinates of current node position.
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-waypoint" or "random-walk".
Data Types: double
Since R2026a
Mode of random walk, specified as "time" or
"distance".
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-walk".
Since R2026a
Time after which the speed and direction change, specified as a positive scalar. Units are in seconds.
Dependencies
To specify this argument, you must specify the WalkMode
argument as "time" and the MobilityModel
argument as "random-walk".
Data Types: double
Since R2026a
Distance after which the speed and direction change, specified as a positive scalar. Units are in meters.
Dependencies
To specify this argument, you must specify the WalkMode
argument as "distance" and the MobilityModel
argument as "random-walk".
Data Types: double
Since R2026a
Current node velocity in Cartesian x-, y-, and z-coordinates, specified as a numeric vector of the form [vx vy vz]. vx, vy, and vz are velocity components in the x-, y-, and z-directions, respectively. Units are in meters per second.
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"constant-velocity".
Data Types: double
Since R2026a
Refresh Interval, specified as a nonnegative scalar. This argument indicates how often the node updates its position and velocity information, with a single refresh occurring at each fixed interval. The units are in seconds.
Data Types: double
Version History
Introduced in R2023bStarting in R2026a, this feature is available in 5G Toolbox™ and also requires a Wireless Network Toolbox license. In prior releases, the feature is available through the Communications Toolbox™ Wireless Network Simulation Library add-on.
The addMobility function supports these new name-value arguments:
MobilityModel,
WalkMode, Time, Distance, Velocity, and
RefreshInterval.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)