Transcript ppt
EE 4365 Introduction to Wireless
Communications
MATLAB® Demonstration—Part 1
Jiawei Liu (T.A.)
[email protected]
Lecture Outline
• Introduction to MATLAB®
• Review of Probability Theory
• Common pseudo random sequence
generators in MATLAB®
• Example: Generating Binary Pseudo Random
Sequences
Introduction to MATLAB®
• Widely used high-level programming language
in both academia and industry
• Numerous toolboxes for many applications
such as signal processing, communications,
biology and finance
• The data structure mainly built on arrays or
vectors
• Brilliant for visualization
Why MATLAB in EE 4365
• Communications systems can be easily
modeled through MATLAB and Simulink
• MATLAB has a large library to facilitate signal
processing, including powerful tools to
visualize signals
• MATLAB is easy to learn and great for
pedagogical purpose
• MATLAB will be continuously used throughout
this course to illustrate key ideas and concepts
How To Get MATALB®
• http://www.utdallas.edu/oit/howto/matlab/
Navigate through MATLAB
• The user interface
• Command Window
Semicolon, ctrl+c
• Editor
• Getting help
• MATLAB’s powerful built-in help system
• Useful commands: doc, help function name (e.g., help
plot), lookfor keyword (e.g., lookfor gaussian)
• MATLAB Central
https://www.mathworks.com/matlabcentral/?s_tid=gn
_mlc
Navigate through MATLAB (Continued)
• Our goal is to
– Generate signals that transmitted in communication
systems
– Simulate signal processing with these signals like real
communications systems
• Living in the digital world
– Any signals in MATLAB must be digitized
– Signals are represented as a sequence of numbers or
samples
• Working with vectors and matrices
– Vectors are simply sequence of numbers
How to Generate Vectors & Signals in
MATLAB
• Colon operator :
• [ ] operator :
•
•
•
•
How to Generate Vectors & Signals in
MATLAB (Continued)
ones(n) – Create array of ones
Zeros(n) – Create array of all zeros
d=size(X) - Return the dimension of array X
Y=sign (X) – Return 1 if x is greater than 0; 0 if
x equals 0; -1 if x is less than 0
Illustration: Amplitude Modulation
• Generate message signal 𝑚 𝑡 = cos 2 ∗ 𝑝𝑖 ∗
A Brief Review of Probability Theory
• Probability Axioms
– Non-negativity: for every even A,
𝑃 𝐴 ≥0
– Additivity: if event A and event B are mutually
exclusive, then
𝑃 𝐴 ∪ 𝐵 = 𝑃 𝐴 + 𝑃 𝐵)
– Normalization:
𝑃 Ω =1
Conditional Probability
• Conditional Probability of 𝑌 given 𝑋:
𝑃 𝑋, 𝑌
𝑃 𝑌|𝑋 =
𝑃[𝑋]
• Bayes’ Rule:
𝑃 𝑋, 𝑌
𝑃 𝑋]𝑃[𝑌|𝑋
𝑃𝑋𝑌 =
=
𝑃[𝑌]
𝑃[𝑌]
Random Variables
• A random variable assigns numbers to
outcomes in the sample space of an
experiment
• Discrete or Continuous
Continuous RVs
• Cumulative Distribution Function (CDF)
• 𝐹𝑋 𝑥 ≜ 𝑃𝑟 𝑥 ≤ 𝛼
• lim 𝐹𝑋 𝑥 = 0
𝑥→−∞
• lim 𝐹𝑋 𝑥 = 1
𝑥→∞
• 𝐹𝑋 𝑥 is non-decreasing in x
• Probability Density Functions (pdf)
𝑑𝐹𝑋 𝑥
𝑓𝑋 𝑥 ≜
𝑑𝑥
Common PDFs
• Uniform distribution: 𝑋 ∼ 𝑈 𝑎, 𝑏 , 𝑎 < 𝑏
1
,
𝑎
≤
𝑥
≤
𝑏,
𝑓𝑋 𝑥 = 𝑏 − 𝑎
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
• Exponential: 𝑋 ∼ 𝐸𝑥𝑝 𝜆 , 𝑓𝑜𝑟 𝜆>0
1 −𝑥
𝜆 , 𝑥 ≥ 0,
𝑒
𝑓𝑋 𝑥 = 𝜆
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Common PDFs (Continued)
• Gaussian (Normal!): 𝑋 ∼ 𝑁 𝜇, 𝜎 2
1
− 𝑥−𝜇 2 /2𝜎 2
𝑓𝑋 𝑥 =
𝑒
2𝜋𝜎 2
• Q-function – Tail Probability of the Standard
Gaussian ~𝑁 0,1):
2
∞
𝑧
1
−
𝑄𝑋 𝑥 =
𝑒 2 𝑑𝑧
2𝜋 𝑥
CDF of Gaussian r.v.: 𝐹𝑋 𝑥 = 1 − 𝑄𝑋 𝑥
Discrete Random Variables
• Finite number of outcomes and denoted as
𝑃𝑋 𝑥 = 𝑃[𝑋 = 𝑥]
• 𝑥 𝑃𝑋 𝑥 = 1
• Bernoulli, 𝑋~𝐵𝑒𝑟𝑛𝑜𝑢𝑙𝑙𝑖 𝑝 , 0 < p < 1
– Probability Mass Function (PMF)
1 − 𝑝, 𝑥 = 0
•𝑓 𝑥𝑝 =
𝑝,
𝑥=1
Discrete Random Variables
(Continued)
• Binomial Distribution: 𝑋~𝐵 𝑁, 𝑝
• N: number of trials;
• P: Probability of success
• 𝑃 𝑋=𝑘 =
𝑛
𝑘
𝑝𝑘 1 − 𝑝)𝑛−𝑘 , 𝑘 = 0, 1, 2, 3, … , 𝑛
• Geometric (Discrete counterpart of Exp. R.v.)
• 𝑃 𝑋 = 𝑘 = 𝑝 1 − 𝑝)𝑘−1 , 𝑘 = 1,2, …
Expectation and Variance of R.V.s
• Expectation or mean, 𝜇 of a r.v. X is,
• Continuous: 𝐸 𝑋 =
• Discrete:
𝐸𝑋 =
∞
𝑥
−∞
∙ 𝑓𝑋 𝑥 𝑑𝑥
𝑥∈Ω 𝑥
• Variance of r.v. X denoted
• 𝜎𝑥2 = 𝐸 𝑋 − 𝐸[𝑋]
2
∙ 𝑃 𝑋 = 𝑥)
by 𝜎 2 :
Random Sequence Generation
• rand(n,1) – create uniformly distributed
random vectors in 0,1
• Create random arrays in specific range [a,b]
• (b-a).*rand(n,1)+a
• randn(n,1) – create normally distributed
random sequence
• Random numbers with specific mean and variance
• Example: mean = a, std = b ⟹ a.randn(n,1)+b
Random Sequence Generation
(Continued)
• randi – create uniformly distributed
pseudorandom integers
• randi([a,b],n,1) – generate an n-by-1 column vector of
uniformly distributed random integers from the sample
interval [-5,5]
• binornd(N,p) – generate binomial random
numbers after N trials with the probability of
success for each trial, p
Random Sequence Generation
(Continued)
• y = randsample(n,k,true,w) – generate
weighted random numbers with weight vector
w.
• p=randperm(n) – returns random permutation
of the integers from [1,n]
• random – general random number generation
function
http://www.mathworks.com/help/stats/rando
m.html
Illustration: Generate binary pseudo
random sequences
• Generate equally likely independent binary bit
stream of bit -1 and +1 with length N=100
Illustration: Generate binary pseudo
random sequences (Continued)
• Generate a N=100 bits long independent
binary bit stream of -1 or +1 with probability
of bit +1 =3/4
Recommended Reading
• How to Generate Signals
– http://www.mathworks.com/help/matlab/ref/spe
cialcharacters.html Special Characters
• Array vs. Matrix Operations
– http://www.mathworks.com/help/matlab/matlab
_prog/array-vs-matrix-operations.html
• MATLAB Tutorial
– http://www.tutorialspoint.com/matlab/
• Documents of each function introduced