elapsetor

生成蜂窝结构的Matlab程序

生成蜂窝结构的Matlab程序

有时候需要用到蜂窝结构,matlab中的六边形生成方法:

pgon = nsidedpoly(6,\'Center\',[X Y],\'Radius\',15);
V = pgon.Vertices;% 获得六个顶点坐标

通过六边形生成蜂窝结构比较麻烦。

以下程序可以快速生成

rc=12;dy=2*rc;dx=rc*sqrt(3);
A = 1:7;
A=pi/3*A;%圆周6等分
num=0;
for yk=[0:dy:100,0:-dy:-100]
    yfun=inline([\'sqrt(3)*x/3+\',num2str(yk)]);%内联函数
    for xk=[0:dx:100,0:-dx:-100]
        xp=xk;
        yp=yfun(xp);
        if -50<xp && xp<50 && -50<yp && yp<50
            T = [xp+1i*yp]+rc*exp(1i*A)*2/sqrt(3);%复数形式
%             Vertx = real(T)\'+50;
%             Verty = imag(T)\'+50;
%             V = [Vertx,Verty];%六个角点的坐标
            num=num+1;
            fprintf(\'第%d个六边形加粗\n\',num);
            plot(T)
            hold on;
            plot(xp,yp)
        end
    end
end

其中V就是每个六边形的顶点坐标。想要获得所有顶点也比较容易。

通过上程序就可以快速重构蜂窝结构用于二维的数值模拟了。

分类:

技术点:

相关文章:

  • 2021-06-19
  • 2021-12-08
  • 2021-07-20
  • 2021-05-20
  • 2022-12-23
  • 2021-12-11
  • 2021-04-13
  • 2021-07-10
猜你喜欢
  • 2021-12-04
  • 2021-11-21
  • 2021-11-12
  • 2021-11-19
  • 2021-11-24
  • 2022-12-23
相关资源
相似解决方案