Select the next waypoint for each node of a VANET simulation.
[D] = NL_M_VanetNextWayPoint(I)
Current corner index for each node.
Next corner index for each node.
NL_M_VanetNextWayPoint selects the next waypoint for each node of a Vehicular Network (VANET).
The corners are numbered {1,2,3,4}. Depending on the road where a node is moving, the direction is fixed, e.g. {1,2,3,4,1...} for the external roads and {1,4,3,2,1...}.
n1=15;//quantity of nodes in the first road n2=15;//quantity of nodes in the second road n3=15;//quantity of nodes in the third road n4=15;//quantity of nodes in the fourth road //corners coordinates P1x=[100 900 900 100]; P1y=[100 100 900 900]; P2x=[130 870 870 130]; P2y=[130 130 870 870]; P3x=[160 160 840 840]; P3y=[160 840 840 160]; P4x=[190 190 810 810]; P4y=[190 810 810 190]; N=[n1 n2 n3 n4]; n=n1+n2+n3+n4; nf=4; i1=int(4*rand(1,n1))+1;//starting corner of the first set of nodes i2=int(4*rand(1,n2))+1;//starting corner of the second set of nodes i3=int(4*rand(1,n3))+1;//starting corner of the third set of nodes i4=int(4*rand(1,n4))+1;//starting corner of the fourth set of nodes indc=[i1 i2 i3 i4] //coordinates of nodes 4 fixed nodes followed by n nodes nodex=[145 145 855 855 P1x(i1) P2x(i2) P3x(i3) P4x(i4)]; nodey=[145 855 855 145 P1y(i1) P2y(i2) P3y(i3) P4y(i4)]; Dind=[NL_M_VanetNextWayPoint(i1) NL_M_VanetNextWayPoint(i2) NL_M_VanetNextWayPoint(i3) NL_M_VanetNextWayPoint(i4)]//application of NL_M_VanetNextWayPoint | ![]() | ![]() |