Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. % Mark Wilson 214136683
  2. % Artem Rozenfeld 214152847
  3. %% Question 1a
  4. clear;
  5. t = 0:0.01:10;
  6. y = 0.1*sind(t)+ 0.2*cos(4*pi*t + 2*pi/6);
  7. plot(t,y)
  8. xlabel('time');
  9. ylabel('function output')
  10. grid;
  11. legend('x(t)')
  12. title('Question 1a')
  13.  
  14. %% Question 1b
  15. clear;
  16. t = 0:0.01:10;
  17. y = 0.1*sind(t)+ 0.2*cos(4*pi*t + 0);
  18. plot(t,y)
  19. hold on;
  20. y = 0.1*sind(t)+ 0.2*cos(4*pi*t + pi/4);
  21. plot(t,y)
  22. hold on;
  23. y = 0.1*sind(t)+ 0.2*cos(4*pi*t + pi/2);
  24. plot(t,y)
  25. hold on;
  26. y = 0.1*sind(t)+ 0.2*cos(4*pi*t + 3*pi/4);
  27. plot(t,y)
  28. hold on;
  29. y = 0.1*sind(t)+ 0.2*cos(4*pi*t + pi);
  30. plot(t,y)
  31. hold off;
  32. xlabel('time');
  33. ylabel('function output')
  34. grid;
  35. legend('ø = 0','ø = 45','ø = 90','ø = 135','ø = 180')
  36. title('Question 1b')
  37.  
  38. %% Question 1c
  39. % Yes, X(t) is a periodic signal.
  40. % It is periodic because the signal repeats
  41. % in a set period with a repeating frequency of 2Hz.
  42. % It might look like the function is rising within the
  43. % given time, because the period is larger than the set t.
  44.  
  45.  
  46. %% Question 2a
  47. clear;
  48. t = 0:0.01:10;
  49. y = exp(-0.1*pi*t);
  50. plot(t,y)
  51. hold on;
  52. y = exp(-0.1*pi*t).*cos(2*pi*t);
  53. plot(t,y,':r')
  54. hold off;
  55. ylabel('function output');
  56. xlabel('time');
  57. grid;
  58. legend('e(t)','x2(t)');
  59. title('Question 2a')
  60.  
  61. %% Question 2b
  62. clear;
  63. t = 0:0.01:10;
  64. y = heaviside((exp(-0.1*pi*(t-2)).*cos(2*pi*(t-2))));
  65. plot(t,y)
  66. ylabel('function output');
  67. xlabel('time');
  68. grid;
  69. legend('x2b(t)');
  70. title('Question 2b')
  71.  
  72.  
  73. %% Question 3a
  74. clear;
  75. Z = 1 + -3i + (7i*10/(7i+10));
  76. display(Z)
  77.  
  78.  
  79. %% Question 3b
  80. clear;
  81. Z = 1 + -3i + (7i*10/(7i+10));
  82. t = 0:0.01:2;
  83. V = 50*sin(10*pi*t);
  84. plot(t,V)
  85. hold on;
  86. I = (50*sin(10*pi*t - atan(imag(Z)/real(Z)))/abs(Z));
  87. plot(t,I)
  88. hold off
  89. ylabel('function output');
  90. xlabel('time');
  91. grid;
  92. legend('V(t)','I(t)');
  93. title('Question 3b')
  94.  
  95. %% Question 4
  96. clear;
  97. output=squarewave(10,2,300);
  98. hold on;
  99. output=squarewave(10,2,1);
  100. hold on;
  101. output=maxpower(10,2,1);
  102. hold off;
  103. legend('square wave','fundamental square wave','maxpower')
  104. title('Question 4')
  105. %% squarewave
  106. function output = squarewave(v,f,length);
  107. t = 0:0.001:1;
  108. y = 0;
  109. for n=1:2:length
  110. output = ((4*v)/pi)*((1/n)*sin(n*2*pi*f*t));
  111. y = output + y;
  112. end
  113. plot(t,y)
  114. ylabel('function output');
  115. xlabel('time');
  116. grid;
  117. legend('show');
  118.  
  119. end
  120. %% maxpower
  121. function output = maxpower(v,f,length);
  122. t = 0:0.001:1;
  123. y = 0;
  124. for n=1:2:length
  125. output = ((4*v)/pi)*((1/n)*sin(n*2*pi*f*t));
  126. y = output + y;
  127. end
  128. y = y.^2;
  129. plot(t,y)
  130. ylabel('function output');
  131. xlabel('time');
  132. grid;
  133. legend('show');
  134.  
  135. end
  136.  
  137.  
  138. %% Question 5a
  139. clear;
  140. t=-5:.001:5;
  141.  
  142. y=-3.*sign(t).*exp(2i*pi*t+0.25*t);
  143. subplot(2,1,1);
  144.  
  145. plot(t,real(y));
  146. title('CT signal real');
  147. xlabel('time');
  148. ylabel('function output');
  149.  
  150. subplot(2,1,2);
  151.  
  152. plot(t,imag(y));
  153. title('CT signal imaginary ');
  154. xlabel('time');
  155. ylabel('function output');
  156.  
  157.  
  158.  
  159. %% Question 5b
  160. clear;
  161. t=-5:.001:5;
  162.  
  163. y=-3.*sign(t).*exp(2i*pi*t+0.25*t);
  164. z=y.*rectangularPulse(t/4);
  165. subplot(2,1,1);
  166. plot(t,real(z));
  167. title('Rectangular Pulse Signal real ');
  168. xlabel('time');
  169. ylabel('function output');
  170.  
  171. subplot(2,1,2);
  172. plot(t,imag(z));
  173. title('Rectangular Pulse Signal imaginary ');
  174. xlabel('time');
  175. ylabel('function output');
  176.  
  177.  
  178.  
  179. %% Question 6
  180. clear;
  181. t = -2:0.01:2;
  182. if (-2<=t<0)
  183. y = 0.25*t;
  184. plot(t,y)
  185. hold on
  186. end
  187. if (0<=t<0.5)
  188. y = 1.5;
  189. plot(t,y)
  190. hold on
  191. end
  192. if (0.5<=t<=2)
  193. y = -t +2;
  194. plot(t,y)
  195. hold off
  196. end
  197.  
  198. ylabel('function output');
  199. xlabel('time');
  200. grid;
  201. legend('0.25t','1.5','-t+2')
  202. title('Question 6')
  203. axis([-2,2,-0.5,2]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement