⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cp1002_create_network.m

📁 这是一本超宽带通信书籍< 超宽带无线通信>>的原代码,ds_uwb,mb_ofdm,脉冲信号的形成
💻 M
字号:
% 
% FUNCTION 10.1 : "cp1002_create_network"
%
% This function generates the positions of a set of nodes
% in a square area and computes the distance between each
% pair of nodes
% The function receives in input:
% - The number of nodes N
% - The sidelength of the square area
% - A flag G to enable/disable the graphical output
% The function returns:
% - A matrix Nx2 containing the (X,Y) positions of each
%   node
% - A matrix NxN containing the distances between each pair
%   of nodes
%
% Programmed by Luca De Nardis
%

function [positions, ranges] = ...
   cp1002_create_network(N,area_side,G)
for i = 1:N
    positions(i,1)=rand*area_side;
    positions(i,2)=rand*area_side;
    j=1;
    for j=1:(i-1)
        ranges(i,j)= sqrt((positions(i,1) -...
           positions(j,1))^2 + (positions(i,2) -...
           positions(j,2))^2);
        while(ranges(i,j)==0)
                X(i)=rand*50;
                Y(i)=rand*50;
                ranges(i,j)=sqrt((positions(i,1)-...
                   positions(j,1))^2+(positions(i,2)-...
                   positions(j,2))^2);
        end
        ranges(j,i)=ranges(i,j);
    end
end
if G
    scatter(positions(:,1),positions(:,2),'filled');
    axis([0 area_side 0 area_side]);
    xlabel('X [m]');
    ylabel('Y [m]');
    box on;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -