Shafayat__

Untitled

May 20th, 2023
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.43 KB | None | 0 0
  1. clc;
  2. clear all;
  3. close all;
  4. t= 0:1:10;
  5. f=10;
  6. x=10*sin(2*f*pi*(t-2));
  7. x1=10*sin(2*f*pi*t);
  8. plot(xcorr(x,x1));
  9. z=xcorr(x,x1);
  10. [autocorr, lags] = xcorr(x,x1)
  11. subplot(3,1,1);
  12. plot(x);
  13. title('Signal');
  14. subplot(3,1,2);
  15. plot(x1);
  16. title('Delayed signal');
  17. subplot(3,1,3);
  18. plot(lags,autocorr);
  19. title('Lags vs autocorrelation-value');
  20. [~, index] = max(autocorr);
  21. delay_sample = abs(lags(index))
  22. Fs=1;
  23. delay_seconds = delay_sample/Fs
  24.  
Advertisement
Add Comment
Please, Sign In to add comment