Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % From (a) y = -cos(x) + 1 represents the probability that a signal's duration is between 0 and x
- % We will plot this function again, and a line at x = pi/4 to answer (b)
- % You only need two points to plot a line for x = pi/4, how would you do it?
- x = 0 : 0.001 : pi/2;
- y = -cos(x) + 1;
- figure;
- hold on;
- plot(x,y);
- plot([pi/4 pi/4], [0 1]); % This plots a line between (pi/4, 0) and (pi/4, 1)
- % The intersection between these two graphs is the answer
- xlabel('x'); ylabel('Probability of signal duration less than x'); title('Cumulative Distributive Function of x');
- hold off;
- % -----EXTRA-----
- t = 0 : 0.001 : pi/2;
- x = 0 : 0.001 : pi/4;
- f = sin(t);
- fx = sin(x);
- figure;
- hold on;
- plot(t, f);
- area(x, fx);
- xlabel('t'); title('Probability Density Function')
- hold off;
- % Area is the answer to the question
- % ---------------
- x = pi/4; % Redefine x to be the point of interest
- 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