matlab 无线网络,matlab如何生成随机无线网络?

先随机生成网络节点

然后在上面将节点连接关系标出来

一般都是怎么做的呢?

谢谢~~~

同问

自己写程序吧,如果对于节点数目有要求

可以用拓扑生成器

自己写一个,很简单的 :)

下面是我正在用的一个程序,应该可以写的更紧凑一些,懒得弄了

function [mt_pos,bs_pos]=cell_scn(nc,nu,d)

% CELL_SCN randomly located mobile terminals (MTs) in NC hexagonal cells.

% The diameter of a hexagonal cell is d, and the number of MTs in each cell

% is NU.

if isempty(find(nc==[1 7 19]))

x = []; y = [];

warning('cell_scn in its current version only supports 1, 7, or 19 cells.');

return;

end

nut = nu*nc; % total # of mobile terminals

r = d/2; % radius of cell

bs_pos = [[0 0]; ...

[0 sqrt(3)]; [3/2 sqrt(3)/2]; [3/2 -1*sqrt(3)/2]; ...

[0 -1*sqrt(3)]; [-3/2 -1*sqrt(3)/2]; [-3/2 sqrt(3)/2];...

[0 2*sqrt(3)]; [3/2 3*sqrt(3)/2]; [3 sqrt(3)];...

[3 0]; [3 -1*sqrt(3)]; [3/2 -3*sqrt(3)/2];...

[0 -2*sqrt(3)]; [-3/2 -3*sqrt(3)/2]; [-3 -1*sqrt(3)]; ...

[-3 0]; [-3 sqrt(3)]; [-3/2 3*sqrt(3)/2]];

bs_pos = bs_pos(1:nc,:) r; % posotions of base stations.

rho = r * sqrt(rand(nut,1));

theta = 2 * pi * rand(nut,1);

mt_pos = [rhocos(theta) rhosin(theta)];

for i=0:nc-1

for j=1:nu

mt_pos(i*nu+j,:) = mt_pos(i*nu+j,:)+bs_pos(i+1,:);

end

end

figure('color','white');

plot(mt_pos(:,1),mt_pos(:,2),'ro','markerfacecolor','r'); hold on;

plot(bs_pos(:,1),bs_pos(:,2),'bh','markerfacecolor','b','markersize',10);

theta = 0:pi/100:2*pi;

tmp_x = r * cos(theta);

tmp_y = r * sin(theta);

for i=1:nc

plot(tmp_x+bs_pos(i,1),tmp_y+bs_pos(i,2),'k-');

end

这个程序不错

但是不符合需求:点的位置很好生成,关键是如何生成随机拓扑结构,并将其标示出来,且用数据结构表示出来拓扑关系。

呵呵

有没有简便的方法?

(

土方法:

1 用n*2矩阵表示点的位置

2 对每个点,检测邻居节点关系

3 依找某种准则(比如概率)确定邻居节点连接关系

4 将其连接关系用连线标示出来

5 回到2

用稀疏矩阵表示连接拓扑

)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值