function [phase,magnitude] = phamag(wave1,wave2,length,frequency,T)
%PHAMAG Summary of this function goes here
%   Detailed explanation goes here
W=hann(length);
wave = [wave1;wave2].*W';
Fs = 1/T;
n = 2^nextpow2(length);
X = fft(wave,n,2)/n;
idx = ceil(frequency*n/Fs);
phase = mod(angle(mean(X(2,idx)))-angle(mean(X(1,idx))),pi);
magnitude = abs(X(2,idx))/abs(X(1,idx));
end

