Advertisement
TwentyEight

(b)

Jan 12th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.96 KB | None | 0 0
  1. % From (a) y = -cos(x) + 1 represents the probability that a signal's duration is between 0 and x
  2. % We will plot this function again, and a line at x = pi/4 to answer (b)
  3. % You only need two points to plot a line for x = pi/4, how would you do it?
  4. x = 0 : 0.001 : pi/2;
  5. y = -cos(x) + 1;
  6. figure;
  7. hold on;
  8. plot(x,y);
  9. plot([pi/4 pi/4], [0 1]); % This plots a line between (pi/4, 0) and (pi/4, 1)
  10. % The intersection between these two graphs is the answer
  11. xlabel('x'); ylabel('Probability of signal duration less than x'); title('Cumulative Distributive Function of x');
  12. hold off;
  13.  
  14. % -----EXTRA-----
  15.  
  16. t = 0 : 0.001 : pi/2;
  17. x = 0 : 0.001 : pi/4;
  18. f = sin(t);
  19. fx = sin(x);
  20. figure;
  21. hold on;
  22. plot(t, f);
  23. area(x, fx);
  24. xlabel('t'); title('Probability Density Function')
  25. hold off;
  26. % Area is the answer to the question
  27.  
  28. % ---------------
  29.  
  30. x = pi/4; % Redefine x to be the point of interest
  31. y = -cos(x) + 1 % This answer is not suppressed so the result is printed out
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement