grid structure in wsn..

1 view (last 30 days)
Susmita Das
Susmita Das on 17 May 2019
Commented: Walter Roberson on 21 May 2019
how to use grid structure in wsn, I have understood that how to deploy nodes in grid structured wsn but I am unable to understand how to use 'for loop' for each cell in grid structure,how to do numbering of cells ,which node is in which cell? which cell is above the other cell. how to feed the coordinates of cells in the for loop..

Accepted Answer

Walter Roberson
Walter Roberson on 17 May 2019
One_grid_info = struct('UID', -inf, 'lat', -inf, 'long', -inf, 'Energy', 10000, 'InputBuffer', [], 'OutputBuffer', []);
nrows = 17;
ncols = 12;
wsn_grid(nrows, ncols) = One_grid_info;
for row = 2:nrows - 1
row_above = row - 1;
row_below = row + 1;
for cols = 2:ncols - 1
col_left = cols - 1;
col_right = cols + 1;
neighbors = sub2ind([nrows, ncols], [row_above, col_left; row_above, col; row_above, col_right; row, col_left; row, col_right; row_below, col_left; row_below, col; row_below, col_right]);
neighbor_info = wsn_grid(neighbors);
do something
end
end
  2 Comments
Susmita Das
Susmita Das on 21 May 2019
How to make an array with alphanumeric values,I want to name the cells in grid structure like
cell=[A1, A2, .....,A26,B1,B2,....]
how can I do so using for loop
Walter Roberson
Walter Roberson on 21 May 2019
cellnames = cellstr(string(('A':'H').') + (1:26));

Sign in to comment.

More Answers (0)

Categories

Find more on WSNs in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!