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.

13 line
391B

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