Simulation of Wireless sensor network using exponential and poisson distribution
Afficher commentaires plus anciens
I have simulated a WSN with 500 nodes in a 1000*1000m^2 network area with Normal and Uniform distribution. Now to simulate the same network with exponential and poisson distribution i have used the following code but its not working:
code for exponential:
rr = exprnd(1,noOfNodes);
netXloc = rr*L;
rr = exprnd(1,noOfNodes);
netYloc = rr*L;
code for poisson:
rr = exprnd(1,noOfNodes);
netXloc = rr*L;
rr = exprnd(1,noOfNodes);
netYloc = rr*L;
can someone please tell me whats the problem with this code
4 commentaires
Walter Roberson
le 16 Mai 2018
What difficulty are you observing?
Nishigandha Dutta
le 17 Mai 2018
Walter Roberson
le 17 Mai 2018
Not enough code posted for us to make suggestions.
Nishigandha Dutta
le 18 Mai 2018
Réponses (1)
Walter Roberson
le 18 Mai 2018
Your code in WSN_normal is overwhelming the graphics system.
Your section
for ii=1:knx
for jj=1:kny
region_x=[(ii-1)*dx,(ii-1)*dx,ii*dx,ii*dx];
region_y=[(jj-1)*dy,jj*dy,jj*dy,(jj-1)*dy];
plot( region_x, region_y)
in = inpolygon(netXloc,netYloc,region_x,region_y);
nn=find(in==1); %number of nodes in i_th sector
netX= netXloc(nn); %x coordnate nodes in i_th sector
netY=netYloc(nn); %y coordnate nodes in i_th sector
connectivity_max=[ ];
for kk=1:length(nn)
dist= sqrt( (netX(kk)- netXloc).^2+ (netY(kk)- netYloc).^2);
n_p=find(dist<R); %number of connected node's number;
x_node_R=netXloc(n_p);%x coordnates of connected node;
y_node_R=netYloc(n_p);%y coordnates of connected node;
connectivity_max(kk)=max(dist(n_p));
for mm=1:length(n_p)
line([netX(kk),x_node_R(mm)], [netY(kk),y_node_R(mm)], 'LineStyle', ':');
end
end
connectivity_info((ii-1)*knx+jj)=max(connectivity_max);
end
end
appears to be attempting to plot node connections by drawing lines between connected nodes.
In my test, the first sector alone has 8221 nodes -- length(nn) is 8221.
Now have a closer look at your assignment to dist. Notice that each of the points in the sector is compared not just to other points in the sector but to all other points, and the ones within range are to be connected, a line drawn to each. That inflates the number of lines to be drawn.
At the particular test entry I am looking at right now, that makes a difference of 1707 connections to be drawn from the point instead of 1656 within the sector.
In the test I am doing right now, it has just finished processing the 136'th entry in the first sector, out of 8221, and it has so far created 363227 line objects -- an average of over 2600 per entry. Extended, we can estimate that would lead to over 21 million line() objects drawn just for the first sector, and over 500 million line() objects by the time the entire 25 sectors were drawn.
Notice by the way that you are drawing undirected lines but that you are not taking care to only draw connections that have not been drawn yet, so each pair of nodes that is in range of each other will have two lines drawn between them.
I suggest that you pause for a moment and ask yourself what the resolution of your display is. If each line to be drawn added one lit pixel to the display, then how many lines can your display fit? If each line lit only one pixel, then 534365000 lines would require a display with a resolution larger than 30000 x 16000. And would be completely unreadable anyhow.
You need to re-think how many nodes you create and re-think the radius of connectivity.
Perhaps you should have a closer look at
RR = exprnd(1, noOfNodes);
and at what the expected size of the output is for that call.
Catégories
En savoir plus sur Poisson Distribution dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!