blochdiff.m

来自「fdtd计算二维光子晶体带隙」· M 代码 · 共 53 行

M
53
字号
function D=BlochDiff(M,n,d,f)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Electromagnetic Finite-Difference Time-Domain %
% Version 1.20, Release 1                       %
%                                               %
%   (C) Copyright 2005                          %
%   Sharif University of Technology             %
%   School of Electrical Engineering            %
%   All Rights Reserved                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


global KappaX KappaY LX LY X Y
global BoundaryType

if BoundaryType==0
    xCoef=0;
    yCoef=0;
elseif BoundaryType==1
    xCoef=1;
    yCoef=1;
elseif BoundaryType==2 | BoundaryType==4
    xCoef=1;
    yCoef=0;
elseif BoundaryType==3 | BoundaryType==5
    xCoef=0;
    yCoef=1;
elseif BoundaryType==6
     xCoef=f;
     yCoef=f;
end

if d==+1    % Forward Difference
    if n==1     % x Difference
        R=xCoef*exp(-j*KappaX*LX)*M(1,:);
        N=[M;R];
    else        % y Difference
        C=yCoef*exp(-j*KappaY*LY)*M(:,1);
        N=[M C];
    end
else        % Backward Difference
    if n==1     % x Difference
        R=xCoef*exp(+j*KappaX*LX)*M(X,:);
        N=[R; M];
    else        % y Difference
        C=yCoef*exp(+j*KappaY*LY)*M(:,Y);
        N=[C M];
    end
end

D=diff(N,1,n);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?