Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. cyfrowe.m
  2. Type
  3. Text
  4. Size
  5. 2 KB (1,911 bytes)
  6. Storage used
  7. 2 KB (1,911 bytes)
  8. Location
  9. 09
  10. Owner
  11. me
  12. Modified
  13. 11:37 AM by me
  14. Opened
  15. 11:37 AM by me
  16. Created
  17. 11:37 AM with Google Drive Web
  18. Add a description
  19. Viewers can download
  20.  
  21. %zadanie 1
  22.  
  23.  
  24. %zadanie 2
  25. t=-20:20;
  26. u1=zeros(1,41);
  27. u1(21:41)=ones(1);
  28. stem(t,u1);
  29. axis([-20 20 0 3])
  30.  
  31.  
  32. t=-20:20;
  33. u1=zeros(1,41);
  34. u1(21+3:41)=ones(1);
  35. stem(t,u1);
  36. axis([-20 20 0 3])
  37.  
  38.  
  39. %zadanie 3
  40. t=[0,3]
  41. x = [1,1]
  42. stem(t,x);
  43. axis([-2 4 0 2])
  44.  
  45.  
  46. % zadanie 4
  47. t=-20:20;
  48. u1=zeros(1,41);
  49. u1(21:41)=ones(1);
  50. u2=zeros(1,41);
  51. u2(26:41)=ones(1);
  52. u3=u1-u2;
  53. stem(t,u3);
  54. axis([-20 20 0 2])
  55.  
  56.  
  57. %zadanie 5
  58. t1=0:1/10:4;
  59. t2=0:1/100:4;
  60. u1 = sin(2*pi*t1);
  61. u2 = sin(2*pi*t2);
  62. stem(t1,u1);
  63. axis([0 4 -2 2])
  64.  
  65. stem(t2,u2);
  66. axis([0 4 -2 2])
  67.  
  68.  
  69. %zadanie 6
  70. t1=0:1/10:4;
  71. t2=0:1/100:4;
  72. u1 = cos(2*pi*t1);
  73. u2 = cos(2*pi*t2);
  74.  
  75. stem(t1,u1);
  76. axis([0 4 -2 2])
  77.  
  78. stem(t2,u2);
  79. axis([0 4 -2 2])
  80.  
  81.  
  82. %zadanie 7
  83. t1 = 0:0.1:10;
  84. u = gaussmf(t,[1 5]);
  85. u1 = gaussmf(t,[1 5]);
  86. subplot(2,1,1);
  87. plot(t,u)
  88. axis([0 10 0 1])
  89. subplot(2,1,2);
  90. stem(t,u);
  91. axis([0 10 0 1])
  92.  
  93.  
  94. %zadanie 8
  95. figure
  96. t = -3:3;
  97. y1=[1,3,5,6,7,9,2];
  98. y2=[2,4,7,2,9,5,6];
  99. y3 = y1 .* y2;
  100.  
  101. stem(t,y3);
  102. axis([-3 3 0 70])
  103.  
  104.  
  105. %zadanie 9
  106. n = 0:20;
  107. x=[1,zeros(1,20)];
  108. a=[1];
  109. b=[1 -0.5 0.7];
  110. y=filter(a,b,x);
  111. stem(n,y)
  112.  
  113. %zadanie 10
  114. n = 128;
  115. k = 0:n;
  116. t = k/128;
  117. A = 1;
  118. fo = 2;
  119. p = 0;
  120. y = A*sin((2*pi*fo*t)+p);
  121. figure
  122. plot(k,y)
  123. axis([0 140 -1 1])
  124.  
  125. %zadanie 11
  126. n = 128;
  127. k = 0:n;
  128. t = k/128;
  129. A = 1;
  130. fo = 5;
  131. p = 0;
  132. y = A*sin((2*pi*fo*t)+p);
  133. figure
  134. plot(k,y)
  135. axis([0 140 -1 1])
  136.  
  137. %zadanie 12
  138. figure
  139. T = 10*(1/50);
  140. fs = 100;
  141. t = 0:1/fs:T-1/fs;
  142. x = sawtooth(2*pi*50*t);
  143. plot(t,x)
  144.  
  145.  
  146. %zadnie 13
  147. figure
  148. T = 10*(1/50);
  149. fs = 500;
  150. t = 0:1/fs:T-1/fs;
  151. x = square(2*pi*50*t);
  152. plot(t,x)
  153. axis([0 0.2 -1.2 1.2])
  154.  
  155.  
  156. %zadanie 14
  157. fs = 10000;
  158. t = -1:1/fs:1;
  159. x1 = tripuls(t,80e-3);
  160. x2 = rectpuls(t,80e-3);
  161. subplot(2,1,1)
  162. plot(t,x1)
  163. axis([-0.1 0.1 -0.2 1.2])
  164. title('Triangular Aperiodic Pulse')
  165. subplot(2,1,2)
  166. plot(t,x2)
  167. axis([-0.1 0.1 -0.2 1.2])
  168. title('Rectangular Aperiodic Pulse')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement