Shafayat__

Untitled

May 12th, 2023
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.44 KB | None | 0 0
  1. x=[-1 2 1];
  2. h=fliplr(x);
  3. C=x.'*h;
  4. k=length(x);
  5. l=length(h);
  6. n=k+l-1;
  7. for i=1:n
  8.     y(i)=0;
  9.     for j=1:k
  10.         s=i-j;
  11.         m=i-j+1;
  12.         if(s<k && m>0)  
  13.             y(i)=y(i)+C(m,j);
  14.         end
  15.     end
  16. end
  17. z=xcorr(x);
  18. subplot(3,1,1);
  19. stem(x);
  20. title('The input Signal x(n)');
  21. subplot(3,1,2);
  22. stem(z);
  23. title('The auto-correlation using function');
  24. subplot(3,1,3);
  25. stem(y);
  26. title('The auto-correlation using logic');
Advertisement
Add Comment
Please, Sign In to add comment