You are on page 1of 8

DIGITAL COMMUNICATION

ASSIGNMENT

1) Write a MATLAB code to produce a randomly generated number that is equally likely to
produce any number from set {0,1,2,.....,9}. Answer:% Digital Communication Assignment Question No:-1 clear all; close all; r=randint(1,1,10); r

2) Write a MATLAB code to produce a randomly generated number that follows Bernoulli
distribution for an arbitrary parameter p. Answer:% Digital Communication Assignment, Question No:-2 clear all; close all; p=input('Enter the probability of success '); if p<=1 b=binopdf(1,1,p); b else disp('Entered value is wrong'); end Output:Enter the probability of success .5 b = 0.5000

3) Write a MATLAB code to simulate a random variable z whose PDF is given by


P(k) = 2-k. Answer:% Digital Communication Assignment Question No:-3 clear all; close all; disp('PDF is of Random variablr z is 2^(-k)'); k=input('Enter the value of k to find F(k) '); Fk=(1/2)^k*log10(2); disp('p(z<=k) is '); Fk Output:Enter the value of k to find F(k) 3 p(z<=k) is Fk = 0.0376

4) Write and execute a MATLAB program to calculate n! For an arbitrary n. Using that
program calculate 64! Answer:% Digital Communication Assignment Question No:-4 clear all; close all; f=1; n=input('Enter the value of n, of which factorial is to be found '); if (n>0) for i=1:n; f=f*i; end; disp('Factorial is, '); f else

disp('Factorial is 1'); end Output:n = 64 Factorial is, f = 1.2689e+089

5) Draw a histogram of random numbers, along with a Gaussian PDF , where = 5 and
= 2. Answer:% Digital Communication Assignment Question No:- 5 clear all; close all; x=1:10; g=normpdf(x,5,2); disp('Mean is 5 and SD is 2'); stem(x,g); Output:Mean is 5 and SD is 2
3

2.5

1.5

0.5

0 -0.15

-0.1

-0.05

0.05

0.1

0.15

0.2

0.25

0.3

0.35

6) Write a MATLAB code to calculate P(x1<=X<=x2) if X is a Gaussian random variable


for an arbitrary x1 and x2. Answer:% Digital Communication Assignment Question No:- 6 clear all; close all; disp('Code to find P(x1<=X<=x2)'); x1=input('Enter the value of x1 '); x2=input('Enter the value of x2 '); u=input('Enter the maen of Gaussian Random variable '); var=input('Enter the variance of the Gaussian Random process '); sig=sqrt(var); if (x1<x2) p=normcdf(x2,u,sig)-normcdf(x1,u,sig); disp('P(x1<=X<=x2) '); p else disp('Entered values are incorrect'); end Output:Code to find P(x1<=X<=x2) Enter the value of x1 4 Enter the value of x2 5 Enter the maen of Gaussian Random variable 4 Enter the variance of the Gaussian Random process 2 P(x1<=X<=x2) , p = 0.2602

7) Use the MATLAB rand function to create a random variable (k), uniformly distributed
over (0,1). Then create a new random variable according to y =-ln(x). Repeat this procedure many times to create a large number of realizations of y.Using these samples, estimate and plot PDF of y. Answer:%Digital communication Assignment Question No:- 7 clear all; close all; k=rand(1,10); y=-log(k); z=normpdf(y,2,4); stem(1:10,z); Output:-

0.1 0.09 0.08 0.07 0.06 0.05 0.04 0.03 0.02 0.01 0

10

8) Calculate the probability of P(|x-a| < b) if x is a Gaussian random variable for an


arbitrary (a , b) > 0. (Specify the mean and variance). Answer:% Digital communication assignment Question No:- 8 clear all; close all; a=input('Enter the value of a, a > 0 ');

b=input('Enter the value of b, b > 0 '); u=input('Enter the mean '); var=input('Enter the variance '); sig=sqrt(var); x=abs(a+b); if (a>0 && b>0) p=normcdf(x,u,sig); disp('P(|x-a|<b) is '); p else disp('Entered value is incorrect '); end Output:Enter the value of a, a > 0 3 Enter the value of b, b > 0 4 Enter the mean 5 Enter the variance 2 P(|x-a|<b) is p = 0.9214

You might also like