Shafayat__

Untitled

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