function [Amp, Phase] = peak(Data,a,b,pre) % finds maximum peak (not maximum point) within the specified range a:b Amp = zeros(length(Data(1,:)),1); Phase = Amp; for i = 1:length(Data(1,:)); c = a+pre; d = b+pre; [A,I] = max(Data(c:d,i)); while (((I == 1) || (I == d-c+1)) && (c ~= d)) if I == 1; c = c+1; elseif I == d-c+1 d = d-1; end [A,I] = max(Data(c:d,i)); end if c == d; Amp(i,1) = 0; Phase(i,1) = 0; else Amp(i,1) = A; Phase(i,1) = I+c-(pre+1); end end end