### Welcome to EDAboard.com

#### Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Status
Not open for further replies.

#### suman_saurav

##### Newbie level 1
I want to assign random channels to random CR nodes(Secondary Users). If two nodes have common channel then only they are connected otherwise not. After that i want to calculate a value for each nodes based on common channel among its neighbors . Based on this values for each nodes I am applying SOC algorithm to find cluster head and hence total clusters.
I have divided my work in 4-5 steps:
My Rough Algorithm :
Step 1 : Assign random channels to each nodes.
Step 2 : Connect two nodes if they have at least common channel.
Step 3 : Apply SOC algorithm and find cluster head (keep note of common channel,no. of nodes,total clusters ,etc.)
Step 4 : Get clusters
Step 5 : Simulate according to the results obtained.

I want to use Matlab (I am a beginner Although).So far I have used this .

Code:
clear;
noOfNodes = rand(5);%randomly assign nodes . I have no idea how to assign random channel to each nodes.
rand('state', 0);
figure(1);
clf;
hold on;
L = 1000;
R = 200; % maximum range for each nodes;
netXloc = rand(1,noOfNodes)*L;
netYloc = rand(1,noOfNodes)*L;
for i = 1:noOfNodes
plot(netXloc(i), netYloc(i), '.');
text(netXloc(i), netYloc(i), num2str(i));
for j = 1:noOfNodes
distance = sqrt((netXloc(i) - netXloc(j))^2 + (netYloc(i) - netYloc(j))^2);
if distance <= R && () % and two nodes have common channel
matrix(i, j) = 1; % there is a link;
line([netXloc(i) netXloc(j)], [netYloc(i) netYloc(j)], 'LineStyle', ':');
else
matrix(i, j) = inf;
end;
end;
end;

Thank You.
Sorry for my english

Last edited by a moderator:

Status
Not open for further replies.