Presentation is loading. Please wait.

Presentation is loading. Please wait.

Communication Theory Lab (1)

Similar presentations


Presentation on theme: "Communication Theory Lab (1)"— Presentation transcript:

1 Communication Theory Lab (1)
Prepared by: Eng.Lamiaa Daoud

2 Agenda MATLAB Revision Random Variable Definition
Types of Random Variables Types and Features Task

3 Variables: ∞ π Syntax Description X=6 Integer Y=[1 2 3 4] Vector
Z=[ ; ] Matrix L=3+4i Complex number M=‘hello’ String R=Inf S=pi π

4 Exponential Functions:
Syntax Description a^b ab exp(a) ea log10(a) log10 a log2(a) log2 a log(a) ln a sqrt(a)

5 Vectors: Description Output Syntax X=[1 3 5 7 9] X=[x1 x2 x3 x4 x5]
X=start: step: end Y=X(2) Y=2nd element in X Y=3 X(3)=4 Set the 3rd element in X to 4 X=[ ] Y=X(2:1:3) Y=2nd to 3rd element in X Y=[3 4] Y=X(1:2:end) Y=1st to last element in X with a step of 2 Y=[1 4 9] Y=X(5:-2:2) Y=5th to 2nd element in X with a step of -2 Y=[9 4 ] Y=X([2 3 5]) Y=2nd 3rd and 5th elements in X Y=[3 4 9]

6 Y= Conjugate transpose of X in case of complex numbers
Vectors: Syntax Description Output Y=X.’ Y=transpose of X Y=[1 3 4 7 9] Y=X’ Y= Conjugate transpose of X in case of complex numbers Y=X.^2 Y=[x12 x22 x32 x42 x52] Y=[ ]

7 Vectors: Description Output Syntax Y=length(X)
Y=number of elements in X Y=5 Y=sum(X) Y=sum of elements of X Y=24 Y=mean(X) Y=sum(X)/length(X) Y=24/5 =4.8 Y=find(X==4) Y=location of element 5 in X Y=3 Y=find(X>5) Y=location of elements >5 in X Y=[4 5] Y=find(X>5 & X<9) Y=location of elements >5 and <9 in X Y=[4] Y=find(X<3 |X>5) Y=location of elements <3and >9 in X Y=[1 4 5 ]

8 Plotting Description X=[x1 x2 x3 x4 x5…………xn] Y=[y1 y2 y3 y4 y5…………yn]
Syntax Description X=[x1 x2 x3 x4 x5…………xn] Y=[y1 y2 y3 y4 y5…………yn] plot(X,Y) Define both vectors then plot X=-pi:0.01*pi:pi; Y=sin(X); Define one vector and define the other as a function of it xlabel(‘x’) label the x axis ylabel(‘sin(x)’) label the y axis title(‘Sine Wave’) Give a title hold on /hold off Plot more than one graph in the same figure figure Create a new figure legend(‘str1’,’str2’,…..) Display a legend

9 Help:

10 Help: Type the functionality you are searching for

11 Notes: Matlab is case sensetive which means that X is not equivalent to x. Typing a ; at the end of every command means not to display the values in the command window after executing the command. Typing a % before a command means it is a comment and the program will not execute it.

12 Random Experiment It is an experiment whose outcome cannot be predicted with certainty Examples: Tossing a Coin Rolling a Die

13 Random Variable Definition
A variable that results due to a random process Example: Rolling a dice Tossing a coin

14 Types of Random variables
Discrete Random Variables The random variable can only take a finite number of values (ex: tossing a coin) Continuous Random Variables The random variable can take a continous of values (phase of the carrier)

15 Mean of a Random Variable
Discrete Random Variable Continuous Random Variable

16 Mean of Discrete Random Variable
Probability mass function P[X=x] Mean: Weighted average

17 Probability Density Functions: (Continuous random variables)
A probability density function: gives the probability that a random variable x takes on values within a range. Probability density f(x) Properties of probability density function: 0 a b 17

18 Variance of the random variable
Variance is a measure of the randomness of the random variable i.e it is a measure of the amount of variation within the values of the random variable.

19 Variance of the random variable
Discrete Random Variable: Continuous Random Variable:

20 Example: Gaussian Random Variable
Probability density function: Where is the mean of the random variable x. is the variance of x.

21 Gaussian (Normal) RV m: mean : variance

22 Task 1 It is required to generate 1000 normally distributed samples with mean 3 and variance 2 Add the previous samples to another 1000 normally distributed samples with mean 4 and variance 3 Get the mean and the variance of the resulted signal What do you notice ?

23 Variancetotal = Variance1 + Variance2
meantotal = mean1 + mean2

24 Task 2 Plot the probability density functions of the previous example on the same graph Notice the mean of the plotted functions from the graph

25 Useful Commands normrnd(mean, standard deviation, number of rows, number of columns)


Download ppt "Communication Theory Lab (1)"

Similar presentations


Ads by Google