📄 semianalysis_discrete_fft_2d.m
字号:
%SemiAnalysis_Discrete_2D.m
%Purpose: Check the agreement between semianalysical method and FFT
%Ref:Linfang Shen, Sailing He, and Sanshui Xiao, Large absolute band gaps
%in two-dimensional photonic crystals formed by large dielectric pixels,
%Physical Review B 66, 165315-1->-6 (2002)
clear;
clear global;
close all;
cnh=50; %Half number of pixels in one cell
pw=1; %Width of pixel
cn=2*cnh; %Number of pixles in one cell
cw=cn*pw; %Width of cell
cwh=cnh*pw; %Half width of cell
HN=cwh;
%Half number of Fourier coefficients
N=cw;
%Total number of Fourier coefficients
fx=-HN:HN-1;
fy=fx;
x=1:HN;
y=x;
[X,Y]=meshgrid(x,y);
T=10;
ebxn=2+cos(2*pi*(X+Y)/T);
%ebxn=rand(cwh);
t=cat(2,ebxn,fliplr(ebxn));
ebxn_1=cat(1,t,flipud(t));
%ebxn_1=ebxn_1+rot90(ebxn_1);
clear t X Y;
hN=0;
hN=hN+1;
figure(hN);
maxv=max(max(ebxn_1));
image(ebxn_1*64/maxv);
colormap(gray);
title('Original data');
%Standard FFT_0
fs00=fft2(ebxn_1)/cw^2;
fs00=fftshift(fs00);
hN=hN+1;
figure(hN);
surfl(fx,fy,real(fs00));
title('Real fs00');
hN=hN+1;
figure(hN);
surfl(fx,fy,imag(fs00));
title('Imagery fs00');
%Semianalysical FS_0
fs10=zeros(cw);
h=waitbar(0,'Calculating fs10...');
for m=1:cw
waitbar(m/cw,h);
flag=2;
for n=1:cw
fs10(m,n)=SquarePixel_ebxn_2D_FC(ebxn,pw,cw,fx(m),fy(n),flag);
end
end
close(h);
hN=hN+1;
figure(hN);
surfl(fx,fy,real(fs10));
title('Real fs10');
hN=hN+1;
figure(hN);
surfl(fx,fy,imag(fs10));
title('Imagery fs10');
disp('SemiAnalysis_Discrete_2D ends');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -