Shafayat__

Untitled

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