What command to move from random node location to specific node location
Show older comments
I want to solve a problem about node placement. Now I want to know how to move node from random placement to specific placement. I need command to move the node. I already create for random node but I don't know how to move the node from random to specific location.
Answers (1)
Mourad KECHIR
on 7 Apr 2015
Hi liza, firstly i am sorry for my english ; i am working on optimal node placement problem , i don't know how your problem is modeled, so i will try to give you an example if you have a matrix binary matrix b : b=1 if node is placed in position (i,j) ( matrix indices):
if true
%%Creating the dimensions of the room
x = linspace(0,24,9);
y= linspace(0,24,9);
% Number of Beacon (nodes)
N=25;
% fixe ramdomly the beacon
b = zeros(9,9);
b(randperm(numel(b), N)) = 1;
if true
%find the coordinate (positions) of the nodes X,Y
[m,n]=find(b==1);
m=m';
n=n';
%
for i=1:length(m)
for j=1:length(n)
B(i,:)=[x(m(i)) y(n(i))] ; %disply coordinate of node (metter)
end
end
end
end
you can move her beacon horizontally or diagonally or in specific position (index) ; example:
if true
% right horizontal
c= b((m(i)),n((i)+1))
b((m(i)),n((i)+1))=b(m(i),n(i)) % horizontale droit
b(m(i),n(i))=c
movH=b
end
%left horizontal
c=b((m(i)),n((i)-1))
b((m(i)),n((i)-1))=b(m(i),n(i)) % horizontale Gauche
b(m(i),n(i))=c
movH=b;
% m and n are vectors containing the indices of the beacons. i = 2 selects the second elements of vector m and n which gives the position (index) of the beacon N°: 2.
i = 3 beacon N° 3
end
we can work together if you want I need help too: you can contact me: mourad.zaime@yahoo.fr I hope my answer will help you.
Categories
Find more on Univariate Discrete Distributions 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!