www.gusucode.com > FDTD计算二维光子带隙的程序 > FDTD计算二维光子带隙的程序/247787/PeakDetect.m

    function Peaks=PeakDetect(w,P)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 TimePoints Threshold

MinimumPower=Threshold*max(P);

Count=1;
for i=3:length(P)-2
    if P(i)>P(i-1) & P(i)>P(i-2) & P(i)>P(i+2) & P(i)>P(i+1) & P(i)>MinimumPower
        Peaks(Count)=w(i);
        Count=Count+1;
    end
end