Mrain

jure popravljeno

May 21st, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.21 KB | None | 0 0
  1. 1a)
  2. clear all
  3. clc
  4. t = -3*pi:0.01:3*pi;
  5. y = 2*cos(3*t) + 3*sin(2*t);
  6. plot(t, y)
  7. title('y=2cos(3t)+3sin(2t)')
  8. xlabel('t')
  9. ylabel('x1(t)')
  10. 1b)------------------------------------------------------------------------------------------------------
  11. clear all
  12. clc
  13. t = -pi:0.01:pi;
  14. subplot(2,1,1)
  15. y = abs(exp(1i*4*t) + exp(1i*11*t));
  16. plot(t, y)
  17. title('e^(4it)+e^(11it)')
  18. xlabel('t')
  19. ylabel('x2(t)')
  20. subplot(2,1,2)
  21. y1 =2*abs(cos((7/2)*t));
  22. plot(t , y1)
  23. title('2|cos(7/2t)|')
  24. xlabel('t')
  25. ylabel('x2(t)')
  26. //////////////////////////////////////
  27. x(t) = e^(j4t) + e^(j11t)
  28. x(t) = e^(j(15/2)t) * [e^(-j(7/2)t) + e^(j(7/2)t)]
  29.  
  30. e^(-j(7/2)t) = cos((7/2)t) - jsin((7/2)t)
  31. e^(j(7/2)t) = cos((7/2)t) + jsin((7/2)t)
  32.  
  33. x(t) = 2*e^(j(15/2)t) * [cos((7/2)t)]
  34. |x(t)| = 2|cos((7/2)t)|
  35. 2a)------------------------------------------------------------------------------------------------------
  36. clear all
  37. clc
  38. n = -20:20;
  39. x1 = 5*sin((1/8)*pi*n);
  40. stem(n, x1)
  41. title('5sin((1/8)pi*n)')
  42. xlabel('n')
  43. ylabel('x[n]')
  44. 2c)------------------------------------------------------------------------------------------------------
  45. m skripta clear all
  46. clc
  47. n = -20:20;
  48. for i=1:length(n)
  49. x(i) = dd1(n(i));
  50. end
  51. stem(n, x)
  52. title('u(n)')
  53. xlabel('n')
  54. ylabel('x2[n]')
  55.  
  56. funkcija function y=dd1(n)
  57. y=0;
  58. if n >= 0
  59. y=1;
  60. end
  61. 2b)------------------------------------------------------------------------------------------------------
  62. clear all
  63. clc
  64. n = -20:20;
  65. x3 = double (n == 3) - 4*double(n == 0) + 2*double(n == 1) + double(n == -2) - 6*double(n == -4) + 5*double(n == -5);
  66. stem(n, x3)
  67. title('δ[n+3] + 2δ[n+1] -4δ[n] + δ[n-2] -6δ[n-4] + 5δ[n-5]')
  68. xlabel('n')
  69. ylabel('x[n]')
  70. 3a)------------------------------------------------------------------------------------------------------
  71. clear all
  72. clc
  73. syms t
  74. ezplot('2*cos(3*t) + 3*sin(2*t)', [-3*pi, 3*pi])
  75. title ('x = 2cos(3t) + 3sin(2t)')
  76. ylabel('x(t)')
  77. 3b)------------------------------------------------------------------------------------------------------
  78. clear all
  79. clc
  80. syms t
  81. x = t*cos(t);
  82. y = t*sin(t);
  83. ezplot(x, y, [0*pi, 20*pi])
  84. title('x = t*cos(t) y = t*sin(t)')
  85. 4a)------------------------------------------------------------------------------------------------------
  86. m skripta clear all
  87. clc
  88. t = -3:0.01:4;
  89. plot(t, x1(t), 'LineWidth', 3)
  90. funkcija function y = x1(t);
  91. for i=1:length(t)
  92. y(i) = 0;
  93. if(0 <= t(i)) & (t(i)<1)
  94. y(i) = t(i);
  95. end
  96. if(1 <= t(i)) & (t(i)<2)
  97. y(i) = -t(i) + 2;
  98. end
  99. end
  100. 4b)------------------------------------------------------------------------------------------------------
  101. funkcija function y = x2(t)
  102. for i=1:length(t)
  103. y(i) = 0;
  104. if(-2 <= t(i)) & (t(i) < -1)
  105. y(i) = t(i) +2;
  106. end
  107. if(-1 <= t(i)) & (t(i) < 0)
  108. y(i) = -t(i);
  109. end
  110. if(0 <= t(i)) & (t(i) < 1)
  111. y(i) = t(i);
  112. end
  113. if(t(i) >= 1)
  114. y(i) = 1;
  115. end
  116. end
  117. m skripta clear all
  118. clc
  119. t = -3:0.01:4;
  120. plot(t, x2(t), 'LineWidth', 3)
  121. 4c)------------------------------------------------------------------------------------------------------
  122. funkcija function y = x3(t)
  123. for i=1:length(t)
  124. y(i) = 0;
  125. if(0 <= t(i)) & (t(i) < 1.5)
  126. y(i) = 1;
  127. end
  128. if(1.5 <= t(i)) & (t(i) < 2)
  129. y(i) = -0.5;
  130. end
  131. end
  132. m skripta clear all
  133. clc
  134. t = -3:0.01:4;
  135. plot(t, x3(t), 'LineWidth', 3)
  136. 5a)------------------------------------------------------------------------------------------------------
  137. clear all
  138. clc
  139. t = -3:0.01:4;
  140. parni_dio = (1/2) * [x1(t) + x1(-t)];
  141. neparni_dio = (1/2) * [x1(t) - x1(-t)];
  142. subplot(3,1,1)
  143. plot(t, x1(t), 'LineWidth', 3)
  144. title('Original')
  145. subplot(3,1,2)
  146. plot(t, parni_dio, 'Linewidth', 3)
  147. title('Parni dio')
  148. subplot(3,1,3)
  149. plot(t, neparni_dio, 'LineWidth', 3)
  150. title('Neparni dio')
  151. 5b)------------------------------------------------------------------------------------------------------
  152. clear all
  153. clc
  154. t = -3:0.01:4;
  155. parni_dio = (1/2) * [x2(t) + x2(-t)];
  156. neparni_dio = (1/2) * [x2(t) - x2(-t)];
  157. subplot(3,1,1)
  158. plot(t, x2(t), 'LineWidth', 3)
  159. title('Original')
  160. subplot(3,1,2)
  161. plot(t, parni_dio, 'LineWidth', 3)
  162. title('Parni dio')
  163. subplot(3,1,3)
  164. plot(t, neparni_dio, 'LineWidth', 3)
  165. title('Neparni dio')
  166. 5c)------------------------------------------------------------------------------------------------------
  167. clear all
  168. clc
  169. t = -3:0.01:4;
  170. parni_dio = (1/2) * (x3(t) + x3(-t));
  171. neparni_dio = (1/2) * (x3(t) - x3(-t));
  172. subplot(3,1,1)
  173. plot(t, x3(t), 'LineWidth', 3)
  174. title('Original')
  175. subplot(3,1,2)
  176. plot(t, parni_dio , 'LineWidth', 3)
  177. title('Parni dio')
  178. subplot(3,1,3)
  179. plot(t, neparni_dio, 'LineWidth', 3)
  180. title('Neparni dio')
  181. 6)-------------------------------------------------------------------------------------------------------
  182. clear all
  183. clc
  184. t = -4:0.01:10;
  185. obrtanje = x3(-t);
  186. skaliranje = x3((1/3)*t);
  187. pomak = x3(t - 3);
  188. subplot(4,1,1)
  189. plot(t, x3(t), 'LineWIdth', 3)
  190. title('Originalni signal')
  191. subplot(4,1,2)
  192. plot(t, pomak, 'LineWIdth', 3)
  193. title('Pomaknuti signal')
  194. subplot(4,1,3)
  195. plot(t, obrtanje, 'LineWIdth', 3)
  196. title('Obrnuti signal')
  197. subplot(4,1,4)
  198. plot(t, skaliranje, 'LineWIdth', 3)
  199. title('Skalirani signal')
  200. 7)-------------------------------------------------------------------------------------------------------
  201. clear all
  202. clc
  203. t = -4:0.01:10;
  204. transformirani = x2(-3*t + 2.5);
  205. subplot(2,1,1)
  206. plot(t, x2(t), 'LineWidth', 3)
  207. title('Originalni')
  208. subplot(2,1,2)
  209. plot(t, transformirani, 'LineWidth', 3)
  210. title('Transformirani')
  211. 8)-------------------------------------------------------------------------------------------------------
  212. clear all
  213. clc
  214. n = -27:25;
  215. x3 = double (n == 3) - 4*double(n == 0) + 2*double(n == 1) + double(n == -2) - 6*double(n == -4) + 5*double(n == -5);
  216. graf1 = -x3;
  217. graf2 = 2*x3;
  218. graf3 = (1/3)*x3;
  219. subplot(4,1,1)
  220. stem(n, x3)
  221. title('x3 = d[n+3] + 2d[n+1] -4d[n] + d[n-2] -6d[n-4] + 5d[n-5]')
  222. xlabel(' ')
  223. ylabel('x[n]')
  224. axis([-20 20 -6 5])
  225. subplot(4,1,2)
  226. stem(n-5, graf1)
  227. title('x3(-n - 5)')
  228. xlabel(' ')
  229. ylabel('x[n]')
  230. axis([-20 20 -5 6])
  231. subplot(4,1,3)
  232. stem(n+8, graf2)
  233. title('x3[2n + 8]')
  234. xlabel(' ')
  235. ylabel('x[n]')
  236. axis([-20 20 -12 10])
  237. subplot(4,1,4)
  238. stem(n-2, graf3)
  239. title('x3[1/3n - 2]')
  240. xlabel(' ')
  241. ylabel('x[n]')
  242. axis([-20 20 -2 1.7])
  243. 9)-------------------------------------------------------------------------------------------------------
  244. clear all
  245. clc
  246. n = 0:30;
  247. x = cos((2*pi*1*n)/7);
  248. x1 = cos((2*pi*(5/2)*n)/7);
  249. x2 = cos((2*pi*6*n)/7);
  250. x3 = cos((2*pi*8*n)/7);
  251. subplot(4,1,1)
  252. stem(n,x)
  253. title('cos(n2pi/7)')
  254. subplot(4,1,2)
  255. stem(n,x1)
  256. title('cos(5npi/7)')
  257. subplot(4,1,3)
  258. stem(n,x2)
  259. title('cos(12npi/7)')
  260. subplot(4,1,4)
  261. stem(n,x3)
  262. title('cos(16npi/7)')
  263. 10)------------------------------------------------------------------------------------------------------
  264. clear all
  265. clc
  266. t = -5:0.01:5;
  267. x = cos(((3*pi*t)/1)-(pi/4)).^2;
  268. x1 = cos(((3*pi*t)/3)-(pi/4)).^2;
  269. x2 = cos(((3*pi*t)/6)-(pi/4)).^2;
  270. subplot(3,1,1)
  271. plot(t,x)
  272. title('(cos(t*3pi/1 - pi/4))^2')
  273. subplot(3,1,2)
  274. plot(t,x1)
  275. title('(cos(t*3pi/3 - pi/4))^2')
  276. subplot(3,1,3)
  277. plot(t,x2)
  278. title('(cos(t*3pi/6 - pi/4))^2')
  279. 11)-------------------------------------------------------------------------------------------------------
  280. clear all
  281. clc
  282. n = 0:40;
  283. x = 2*sin((3*pi)/4*n + 1/3);
  284. x1= 1.5*cos(n/7 + pi/5);
  285. x2 = cos(pi/4*n).*cos(pi/8*n);
  286. x3 = 3*cos(pi/8*n) + 2*sin(pi/2*n) - 4*sin(pi/4*n);
  287. subplot(4,1,1)
  288. stem(n,x)
  289. title('2sin(3pi/4n + 1/3)')
  290. subplot(4,1,2)
  291. stem(n,x1)
  292. title('1.5cos(n/7 + pi/5)')
  293. subplot(4,1,3)
  294. stem(n,x2)
  295. title('cos(pi/4n)cos(pi/8n)')
  296. subplot(4,1,4)
  297. stem(n,x3)
  298. title('3cos(pi/8n) + 2sin(pi/2n) - 4sin(pi/4n)')
Advertisement
Add Comment
Please, Sign In to add comment