Hi... I am doing my mtech project on localization in underwater sensor network using neural network . I have matlab code for localization but i do not know how it would be implemented in neural network.could you please help me?

2 views (last 30 days)
clear;
close all;
BorderLength=100;
NodeAmount=100;
BeaconAmount=10;
UNAmount=NodeAmount-BeaconAmount;
R=50;
% D=zeros(NodeAmount,NodeAmount);
h=zeros(NodeAmount,NodeAmount);
X=zeros(2,UNAmount);
C=BorderLength.*rand(2,NodeAmount);
Sxy=[[1:NodeAmount];C];
Beacon=[Sxy(2,1:BeaconAmount);Sxy(3,1:BeaconAmount)];
UN=[Sxy(2,(BeaconAmount+1):NodeAmount);Sxy(3,(BeaconAmount+1):NodeAmount)];
plot(Sxy(2,1:BeaconAmount),Sxy(3,1:BeaconAmount),'r*',Sxy(2,(BeaconAmount+1):NodeAmount),Sxy(3,(BeaconAmount+1):NodeAmount),'k.')
xlim([0,BorderLength]);
ylim([0,BorderLength]);
title('sensornodes') ;
xlabel('width of areas');
ylabel('length of areas');
for i=1:NodeAmount
for j=1:NodeAmount
Dall(i,j)=((Sxy(2,i)-Sxy(2,j))^2+(Sxy(3,i)-Sxy(3,j))^2)^0.5;
if (Dall(i,j)<=R)&&(Dall(i,j)>0)
h(i,j)=1;
elseif i==j
h(i,j)=0;
else h(i,j)=inf;
end
end
end
for k=1:NodeAmount
for i=1:NodeAmount
for j=1:NodeAmount
if h(i,k)+h(k,j)<h(i,j)
%min(h(i,j),h(i,k)+h(k,j))
h(i,j)=h(i,k)+h(k,j);
end
end
end
end
h1=h(1:BeaconAmount,1:BeaconAmount);
D1=Dall(1:BeaconAmount,1:BeaconAmount);
for i=1:BeaconAmount
dhop(i,1)=sum(D1(i,:))/sum(h1(i,:));
end
D2=Dall(1:BeaconAmount,(BeaconAmount+1):NodeAmount);
for i=1:BeaconAmount
for j=1:UNAmount
if min(D2(:,j))==D2(i,j)
Dhop(1,j)=D2(i,j);
end
end
end
Dhop;
hop1=h(1:BeaconAmount,(BeaconAmount+1):NodeAmount);%
for i=1:UNAmount
hop=Dhop(1,i);
Distance(:,i)=hop*hop1(:,i);
end
d=Distance;
for i=1:2
for j=1:(BeaconAmount-1)
a(i,j)=Beacon(i,j)-Beacon(i,BeaconAmount);
end
end
A=-2*(a');
% d=d1';
for m=1:UNAmount
for i=1:(BeaconAmount-1)
B(i,1)=d(i,m)^2-d(BeaconAmount,m)^2-Beacon(1,i)^2+Beacon(1,BeaconAmount)^2-Beacon(2,i)^2+Beacon(2,BeaconAmount)^2;
end
X1=inv(A'*A)*A'*B;
X(1,m)=X1(1,1);
X(2,m)=X1(2,1);
end
for i=1:UNAmount
error(1,i)=(((X(1,i)-UN(1,i))^2+(X(2,i)-UN(2,i))^2)^0.5);
end
figure;plot(error,'o')
title('Localization error')
xlim([0,BorderLength]);
ylim([0,BorderLength]);
xlabel('width of areas');
ylabel('length of areas');
error=sum(error)/UNAmount
Accuracy=error/R;
  5 Comments
Greg Heath
Greg Heath on 16 Feb 2014
Edited: Walter Roberson on 28 Aug 2015
I doubt if anyone will consider your code because
  1. It is not formatted
  2. It has more than 1 statement per line
  3. It has no explanatory comments
  4. It Will not run when cut and pasted
  5. It has unnecessarily long variable names (try BA, NA, UNA, BL,...)
  6. There is no info about what has happened when you have tried to run it (e.g., erroneous results? error messages?)

Sign in to comment.

Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!