topology.m
来自「无线通信系统中的空时编码的仿真程序。多天线发送」· M 代码 · 共 36 行
M
36 行
function [T,R]=topology
clear all;
clf;
a=10; % uniform distribution between 0 and a
N=8;
trange=1;
T=unifrnd(0,a,2,N);% there are totally N transmission nodes in the network
plot(T(1,:),T(2,:),'ro','MarkerSize',7);
axis([0,10,0,10]);
R=ones(2,N);
c=ones(2,N);
incide=zeros(1,N);
i=1;
while i<N+1
c1=unifrnd(0,a,2,1);
c(1,:)=c1(1,1);
c(2,:)=c1(2,1);
incidefind=find(incide);
for j=1:1:length(incidefind)
c(1,incide(1,j))=100;
c(2,incide(1,j))=100;
end
abst=((T(1,:)-c(1,:)).^2+(T(2,:)-c(2,:)).^2).^0.5;
[minvalue,incide1]=min(abst);
if minvalue<trange
R(1,incide1)=c1(1,1);
R(2,incide1)=c1(2,1);
incide(1,i)=incide1;
i=i+1;
end %the receiving node is in the transmission range
end %there are totally N receiving nodes
hold on;
plot(R(1,:),R(2,:),'bo','MarkerSize',7);
for m=1:N
plot([T(1,m) R(1,m)],[T(2,m) R(2,m)],'r');
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?