Code covered by the BSD License  

Highlights from
Mobile user Localization in WSN

Mobile user Localization in WSN

by

 

Dynamic Triangular location method determines the position of mobile user inside a building.

cost.m
m=1;
for i=0:pi/180:2*pi
    if(p==1)
        D2(m)=sqrt((P(2,1)-d(1)*cos(i))^2+(P(2,2)-d(1)*sin(i))^2);
        D3(m)=sqrt((P(3,1)-d(1)*cos(i))^2+(P(3,2)-d(1)*sin(i))^2);
        e2(m)=abs(D2(m)-d(2));
        e3(m)=abs(D3(m)-d(3));
        subplot(3,1,1);
        plot(m,D2(m),'k.');
        hold on
        grid on
        xlabel('angle in degrees')
        ylabel('distance')
        title('variation in distance with angle')
        subplot(3,1,2);
        plot(m,D3(m),'b.');
        xlabel('angle in degrees')
        ylabel('distance')
        title('variation in distance with angle')
        hold on
        grid on
    elseif(p==2)
        D1(m)=sqrt((P(1,1)-d(1)*cos(i))^2+(P(1,2)-d(1)*sin(i))^2);
        D3(m)=sqrt((P(3,1)-d(1)*cos(i))^2+(P(3,2)-d(1)*sin(i))^2);
        e1(m)=abs(D1(m)-d(1));
        e3(m)=abs(D3(m)-d(3));
        subplot(3,1,1);
        plot(m,D1(m),'k.');
        hold on
        grid on
        xlabel('angle in degrees')
        ylabel('distance')
        title('variation in distance with angle')
        subplot(3,1,2);
        plot(m,D3(m),'b.');
        hold on
        grid on
        xlabel('angle in degrees')
        ylabel('distance')
        title('variation in distance with angle')
    else
        D1(m)=sqrt((P(1,1)-d(1)*cos(i))^2+(P(1,2)-d(1)*sin(i))^2);
        D2(m)=sqrt((P(2,1)-d(1)*cos(i))^2+(P(2,2)-d(1)*sin(i))^2);
        e1(m)=abs(D1(m)-d(1));
        e2(m)=abs(D2(m)-d(2));
        subplot(3,1,1);
        plot(m,D1(m),'k.');
        hold on
        grid on
        xlabel('angle in degrees')
        ylabel('distance')
        title('variation in distance with angle')
        subplot(3,1,2);
        plot(m,D2(m),'b.'); 
        hold on
        grid on
        xlabel('angle in degrees')
        ylabel('distance')
        title('variation in distance with angle')
    end
m=m+1;
end

Contact us