Guest User

Untitled

a guest
Jul 15th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.63 KB | None | 0 0
  1. clear all;
  2. t=-2:1:6;
  3. x=[0,0,1,1,1,1,1,0,0];
  4.  
  5. subplot(4,1,1);
  6. stem(t,x);
  7. hold on;
  8. grid on;
  9. axis equal;
  10.  
  11. tt=-2:1:9;
  12. y=[0,0,0,1,2,3,2.5,2,1.5,1,0.5,0]
  13.  
  14. subplot(4,1,2);
  15. stem(tt,y);
  16. grid on;
  17. axis equal;
  18.  
  19. N = length(x) + length(y) -1
  20.  
  21. subplot(4,1,3);
  22.  
  23. for n=1:N
  24.     z(n)=0;
  25.     for k=1:n-1
  26.  
  27.         if k > length(x)
  28.             x(k)=0;
  29.         end
  30.         if n-k > length(y)
  31.                 y(n-k)=0;
  32.         end
  33.             z(n)=z(n) + x(k) *y(n-k)    
  34.     end
  35. pause;
  36. stem(z);
  37. axis([0,20,0,20]);
  38. hold on;
  39.     end
  40.  
  41.  
  42. % subplot(4,1,3);
  43. % stem(z);
  44.  
  45. z1=conv(x,y);
  46. subplot(4,1,4);
  47. stem(z1);
  48. axis([0,20,0,20]);
Add Comment
Please, Sign In to add comment