topo.m

来自「A wireless channel implemenatation in MA」· M 代码 · 共 30 行

M
30
字号
function [node] = topo(maxn, maxx, maxy, drawFigure);
% Generate network topology

% S = rand('state');
% rand('state',0);
node = rand(maxn,2);
node(:,1) = node(:,1)*maxx;
node(:,2) = node(:,2)*maxy;
% rand('state',S);

if drawFigure >= 1
    % make background white, run only once
    colordef none,  whitebg
    figure(1);
    axis equal
    hold on;
    box on;
    % grid on;
    plot(node(:, 1), node(:, 2), 'k.', 'MarkerSize', 5);
    title('Network topology');
    xlabel('X');
    ylabel('Y');
    axis([0, maxx, 0, maxy]);
    set(gca, 'XTick', [0; maxx]);
    set(gca, 'YTick', [maxy]);
end

% line([info(i, 2), info(k, 2)], [info(i, 3), info(k, 3)], 'Color', 'k', 'LineStyle', '-', 'LineWidth', 1.5);
return;

⌨️ 快捷键说明

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