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(X(1,idx))-angle(X(2,idx))+pi,2*pi)-pi; magnitude = X; for i=1:2 subplot(2,1,i) plot(0:(Fs/n):(Fs/2-Fs/n),abs(X(i,1:n/2))) title(['Row ',num2str(i), ' in the Frequency Domain']) end end