本文介绍了代表在移动通信系统中使用的蜂窝网络的六边形网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Matlab来说还比较陌生,我想生成一个六边形网格,该网格代表一个蜂窝网络,其中每个六边形都有特定的行为.

I am relatively new to Matlab and I want to generate a hexagonal grid that represents a cellular network where each hexagon has a specific behaviour.

我的问题是如何从方格变为十六进制格(传递矩阵)?这就是我到目前为止所拥有的.

My question is how does one go from a square grid to hex grid (transfer matrix)?. This is what I have so far.

[X,Y] = meshgrid(0:60);
figure(1), plot(X,Y,'b')
hold on, plot(Y,X,'b')
axis square

推荐答案

几年前,我写了一些代码来做到这一点:

A few years ago I wrote some code to do just that:

%// Define input data:
close all
clear all
M_max = 14; %// number of cells in vertical direction
N_max = 10; %// number of cells in horizontal direction
trans = 1;  %// hexagon orientation (0 or 1)

%// Do the plotting:
hold on
for m = -M_max:M_max
    for n = -N_max:N_max
        center = [.5 sqrt(3)/2] + m*[0 -sqrt(3)] + n*[3/2 sqrt(3)/2];
        if ~trans
            plot([center(1)-1 center(1)],[center(2) center(2)])
            plot([center(1) center(1)+1/2],[center(2) center(2)+sqrt(3)/2])
            plot([center(1) center(1)+1/2],[center(2) center(2)-sqrt(3)/2])
        else %// exchange the two arguments to `plot`
            plot([center(2) center(2)],[center(1)-1 center(1)])
            plot([center(2) center(2)+sqrt(3)/2],[center(1) center(1)+1/2])
            plot([center(2) center(2)-sqrt(3)/2],[center(1) center(1)+1/2])
        end %if
    end %for
end %for
plot([-15 15],[0 0],'-.') %// adjust length manually
plot([-15 15],[-15*sqrt(3) 15*sqrt(3)],'-.') %// adjust length manually
axis image
set(gca,'xtick',[])
set(gca,'ytick',[])
axis([-10 10 -13.3 13.3]) %// adjust axis size manually
set(gca,'Visible','off') %// handy for printing the image

例如,这是使用以上数据生成的图像:

For example, this is the image generated with the above data:

这篇关于代表在移动通信系统中使用的蜂窝网络的六边形网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-17 22:15