image thumbnail

VANET node - RoadSide Unit scenario simulations

by

 

This file contains matlab simulations of nodal interaction scenarios in VANETs

Draw2SeparateRoads.m
axis([0 100 0 100]);hold on
nodes = 5;
PauseTime = 0.01; 
[x,y] = ginput(nodes);
plot(x,y,'--ys','LineWidth',2,...
                'MarkerEdgeColor','b',...
                'MarkerFaceColor','b',...
                'MarkerSize',4)
            
[p,q] = ginput(nodes);
plot(p,q,'--gs','LineWidth',2,...
                'MarkerEdgeColor','b',...
                'MarkerFaceColor','b',...
                'MarkerSize',4)
            
xp = x(1);
yp = y(1);
pp = p(1);
qp = q(1);
m = 0; 
n = 0; 
for i = 2:nodes
    xc = x(i); 
    yc = y(i); 
    xp = x(i-1);
    yp = y(i-1);
    pc = p(i);
    qc = q(i);
    pp = p(i-1);
    qp = q(i-1);
    
    
    m = floor(sqrt((xp-xc)*(xp-xc)+(yp-yc)*(yp-yc)))
    n = floor(sqrt((pp-pc)*(pp-pc)+(qp-qc)*(pp-qc)))
    a1 = linspace(xp,xc,m);
    b1 = linspace(yp,yc,m);
    a2 = linspace(pp,pc,m);
    b2 = linspace(qp,qc,m);    
        for j = 2:m
        h1 = plot(a1(j),b1(j),'*r')
        h2 = plot(a2(j),b2(j),'*r')
        pause(PauseTime);
        set(h1,'Visible','off');
        set(h2,'Visible','off');
        end
end

Contact us