You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 line
388B

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