grid structure in wsn..

1 次查看(过去 30 天)
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..

采纳的回答

Walter Roberson
Walter Roberson 2019-5-17
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 个评论
Susmita Das
Susmita Das 2019-5-21
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 2019-5-21
cellnames = cellstr(string(('A':'H').') + (1:26));

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 WSNs 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by