필터 지우기
필터 지우기

how to create a 4*4 cell-grid structure in wsn using matlab and randomly deploy nodes in it.please help.

조회 수: 1 (최근 30일)
I am creating a wsn structure wth 4*4 cell grids.I have used the following code to create the 4*4 cell-grid structure but now i have to randomly deploy 100 nodes in them.how could it be done?please help.
maNrGrid = 4; % Number Of Grids
x = linspace(0, 100, NrGrid+1);
[X,Y] = meshgrid(x);
figure(1)
plot(X,Y,'k')
hold on
plot(Y,X,'k')
hold off
set(gca, 'Box','off', 'XTick',[], 'YTick',[])
axis square

채택된 답변

Walter Roberson
Walter Roberson 2015년 6월 9일
maNrGrid = 4;
coords = rand(100,2) * maNrGrid + 1;
The K'th sensor is located at (coords(K,1), coords(K,2)), and each of those will be a value from a hair over 1 to a hair less than 5.
scatter(coords(:,1),coords(:,2));
set(gca, 'XTick', 1:maNrGrid+1, 'YTick', 1:maNrGrid+1)
grid on

추가 답변 (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