addMobility
Description
This feature also requires the Wireless Network Toolbox™ product.
addMobility( adds a
default mobility model (random waypoint) to one or more wireless local-area network (WLAN)
nodes, wnode)wnode. 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.
addMobility(
sets the mobility configuration parameters using one or more optional name-value arguments.
For example, wnode,Name=Value)PauseDuration=0.02 sets the pause duration of a WLAN node to
0.02 seconds. If you set 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
This example enables you to:
Create and configure a WLAN with an access point (AP) node and a station (STA) node.
Add application traffic from the AP node to the STA node.
Simulate the WLAN and retrieve the statistics of the AP node and the STA node.
Create a wireless network simulator.
networksimulator = wirelessNetworkSimulator.init();
Create a wlanDeviceConfig object, specifying the operating mode and beacon interval. Use this configuration to create a WLAN node and specify its name and position.
deviceCfg = wlanDeviceConfig(Mode="AP",BeaconInterval=5); apNode = wlanNode(Name="AP",Position=[0 10 0],DeviceConfig=deviceCfg);
Create a WLAN node with the default device configuration. Confirm that the default mode is STA.
staNode = wlanNode(Name="STA",Position=[5 0 0]);Add a random waypoint mobility model to the WLAN node with the default device configuration. Set the shape of the node's mobility area to "circle".
addMobility(staNode,BoundaryShape="circle",RefreshInterval=0.1)Associate the STA node with the AP node using the associateStations function.
associateStations(apNode,staNode);
Create a networkTrafficOnOff (Wireless Network Toolbox) object to generate an On-Off application traffic pattern. Specify the data rate in kilobits per second and the packet size in bytes.
traffic = networkTrafficOnOff(DataRate=100,PacketSize=10);
Add application traffic from the AP node to the STA node.
addTrafficSource(apNode,traffic,DestinationNode=staNode);
Add the AP node and STA node to the wireless network simulator.
addNodes(networksimulator,{apNode,staNode});Set the simulation time in seconds and run the simulation.
simulationTime = 0.5; run(networksimulator,simulationTime);
Get and display the physical layer (PHY) statistics that correspond to the AP node and STA node.
apStats = statistics(apNode); staStats = statistics(staNode); disp(apStats.PHY)
TransmittedPackets: 1243
TransmittedPayloadBytes: 58779
ReceivedPackets: 1146
ReceivedPayloadBytes: 16044
DroppedPackets: 0
disp(staStats.PHY)
TransmittedPackets: 1146
TransmittedPayloadBytes: 16044
ReceivedPackets: 1243
ReceivedPayloadBytes: 58779
DroppedPackets: 0
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(wnode,PauseDuration=0.02) sets the pause duration
for a WLAN node, after it reaches a target waypoint, to 0.02 seconds.
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 WLAN 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 WLAN 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 WLAN 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)