当前位置 : 安防网>安防技术>图形图像>阅读正文

Matlab编程画六边形阵列的程序

作者: 时间:2008-02-19
close all
rc=4;dy=2*rc;dx=rc*sqrt(3);
A=pi/3*[1:7];
hold on;
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;
            plot([xp+i*yp]+rc*exp(i*A)*2/sqrt(3),'k','linewidth',2);
            plot(xp,yp,'.','markersize',6);
        end
    end
end
axis square
plot([0,0],[-50,50],'r:');
plot([-50,50],[0,0],'r:');
plot(50*sqrt(2)*exp(i*[pi/2*[1:5]+pi/4]),'b');
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册