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