1.定义结构坐标
2.for循环遍历构建
load("Full1_jujiao_1550_FDTD.mat");
nm=1e-9;%定义纳米
um=1e-6;%定义微米
period=1.3*um; %单位是um 结构周期
%period=100; %单位是um 结构周期
r=130/2*um; %透镜半径
np = round(r/period);
x_mask = period*(-np+1/2:1:np-1/2); %确定每个单元柱的坐标
y_mask = period*(-np+1/2:1:np-1/2);
[X_mask,Y_mask]=meshgrid(x_mask,y_mask);
a = 1;
%figure
for i=1:100
for j=1:100
rectangle('Position',[x_mask(i) y_mask(j) pr_outputs(a,1) pr_outputs(a,2)],'FaceColor',[0 0 0])
%rectangle('Position',[x_mask(i) y_mask(j) pr_outputs(a,1) pr_outputs(a,2)])
a = a+1;
end
end
set(gca,'xtick',[],'ytick',[],'xcolor','w','ycolor','w')
set(gca,'xticklabel',[],'yticklabel',[])
%set(gcf,'Position',[0,0,1300,1300])
axis off;
%exportgraphics(gca,'Peppers300.jpg','Resolution',1300)
%axis equal
% 可以保存图形为图片文件
saveas(gcf, 'Test2.png');
3.效果图
![](https://img-blog.csdnimg.cn/direct/199404d71e6f4ba29a10a6286fd4eced.png)