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..
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!