76
1 MATLAB Models for PHY (for beginners) Dominik Schulz 2010 – 06 – 17

MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

  • Upload
    others

  • View
    15

  • Download
    1

Embed Size (px)

Citation preview

Page 1: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

1

MATLAB Models for PHY

(for beginners)

Dominik Schulz2010 – 06 – 17

Page 2: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 3: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

3

General Stuff About MATLAB

MATLAB is......built by The MathWorks...matrix-vector based...good for linear algebra...able to deal with large data sets...very popular in science...very powerful and has a large set of extra toolboxes...available for multiple operating systems (Windows, Linux, Mac OS X)...able to use C-bindings (MEX files)...loosely typed...rudimentary object oriented

MATLAB is not...…a general purpose programming language...open source and free to use...fully compatible between major versions...meant to write stand-alone programs

Page 4: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

4

GUI

http://www.mathworks.de/products/matlab/images/matlabdesktop_lg.jpg

Page 5: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

5

GUI

http://www.mathworks.de/products/matlab/images/matlabdesktop_lg.jpg

Command Window(console)

Page 6: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

6

GUI

http://www.mathworks.de/products/matlab/images/matlabdesktop_lg.jpg

Workspace(list of variables)

Page 7: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

7

GUI

http://www.mathworks.de/products/matlab/images/matlabdesktop_lg.jpg

Matrix Editor

Page 8: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

8

GUI

http://www.mathworks.de/products/matlab/images/matlabdesktop_lg.jpg

Editor(edit m-files here)

Page 9: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

9

GUI

http://www.mathworks.de/products/matlab/images/matlabdesktop_lg.jpg

Plot Windows

Page 10: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 11: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

11

Syntax - Scalars

foo1 = 123; % define a scalarfoo2 = 321; % define another scalar

mySum = foo1 + foo2 % compute the sum and print the % result on the console (due to % the missing semicolon at the end)

myProd = foo1 * foo2; % Guess what it does! ;-)myFrac = foo2 / foo1; % ...

cmplx1 = 5 + 3i; % define a complex scalarcmplx2 = 2*exp(i*pi/4) % exponential complex notationcmplx3 = sqrt(2)*(1 + 1i); % same as cmplx3

myCmplxSum = cmplx1 - cmplx2; myCmplxProd = cmplx1 * complx2;myCmplxFrac = cmplx1 / cmplx2;

abs_value = abs(cmplx2) % result: 2

Page 12: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

12

Syntax - Vectors

foo = 123; % define a scalarfoo2 = 5 + 3i; % define a complex scalar

a1 = [1 2 3 4 5]; % define a row vectora2 = 1:5; % same as abovex = length(a1); % result: 5 b1 = [1 4 7 10] % another row vectorb2 = 1:3:10; % same as above

fibNo = [1 1 2 3 5 8 13].'; % define a column vector

d = [a1 b1]; % concatenation of vectors

negNo = 0:-0.1:-1e5; % negative values in -0.1 stepsaNegNo = negNo(11); % result: -1

someNegNo = negNo(20:100) % result: [-1.9 … -9.9]moreNegNo = negNo(end-9:end) % result: last 10 values of negNo

Page 13: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

13

Syntax – Matrices (1)

myMatrix = [1 2 3; 4 5 6]; % define a Matrix as % .- -. % | 1 2 3 | % | 4 5 6 | % `- -'

myMatrixTranspose = myMatrix.' % result: % .- -. % | 1 4 | % | 2 5 | % | 3 6 | % `- -'

[r, c] = size(myMatrix); % result: [2 3]

Page 14: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

14

Syntax – Matrices (2)

myMatrix = [9 7; 4 5] + i*[2 3; 7 10]; % define a Matrix as % .- -. % | 9+2i 7+3i | % | 4+7i 5+10i | % `- -'

myTranspose1 = conj(myMatrix).'; % conjugate transpose % (Hermitian transpose) % % .- -. % | 9-2i 4-7i | % | 7-3i 5-10i | % `- -'

myTranspose2 = myMatrix'; % same as above

identity = eye(3); % 3x3 identity matrixz = zeros(100, 50); % 100x50 matrix of only zerosz = ones(20, 77); % 20x77 matrix of only ones

Page 15: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

15

Syntax – Matrix-Vector Operations

A = [5 3 3; 6 7 8; 9 2 2; 7 6 7]; % 4x3 matrixM = [1 3 4; -3 2 5; -4 -5 1]; N = [3 0 2; 2 3 0; 0 2 3];a = [10 -5 3]';b = 1:3';

B = A * A'; % result: 4x4 matrixC = A' * A; % result: 3x3 matrix

P = N.^2; % elementwise squareQ = N^2; % same as: Q = N*N;

x = M + N; % matrix additiony = M – N; % matrix subtraction

ep = a .* b; % elementwise productip = a' * b; % inner product (→ scalar)op = a * b'; % outer product (→ matrix)

c = A * a; % Compute a new row vector % Not possible: c = a*A

Page 16: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

16

Syntax – Loops

% version 1a = 0;for idx = 1:0.5:10; a = a + idx;end

% version 2a = 0; b = 1;while b <= 10 a = a + b; b = b + 0.5;end

% This is much faster, since no loop is used:a = sum(1:0.5:10);

If you're about to write a loop, think twice!

Most loops can be replacedby matrix-vector operations

which are much faster.

Page 17: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

17

Plotting (1)

% just a simple line plot:plot(<x-value vector>, <y-value vector>[, <fomat>, [...]])

% plot with logarothmic y-axis:semilogy(<x-value vector>, <y-value vector>[, <fomat>, [...]])

% plot with logarothmic x-axis:semilogx(<x-value vector>, <y-value vector>[, <fomat>, [...]])

% double logarothmic plot:loglog(<x-value vector>, <y-value vector>[, <fomat>, [...]])

% set x-label / set y-label:xlabel(<string>)ylabel(<string>)

% set plot title:title(<string>)

some plot commands (syntax):

for a full listof commands type

'help <command>' in the command

window

Page 18: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

18

Plotting (2)

x = 0:0.1:2*pi;y = sin(x); % compute sine function for all x valuesplot(x, y); % plot the sine function

xlabel('angle [rad]'); % label x-axisylabel('sin(x)'); % label y-axistitle('sine function'); % give the plot a title

simple plot example:

clf; % clear figure (clears all previous plotting propeties)n = -1:0.09:1;semilogy(n, n.^2, '-'); % line plot with logarithmic y-axishold on; % do not use a new plot window for % the following plot() commandssemilogy(n, n.^4, 'ro'); % second plot using red circles

legend('f(x)=x^2', 'f(x)=x^4'); % set legend for both plotsxlabel('x'); ylabel('log(f(x))'); % set labels

semi-logarithmic plots on a single diagram:

Page 19: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 20: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

20

GNU Octave

advantages:GPL licensedworks on any system that supports the GNU compiler collection (GCC)runs nearly every MATLAB program(depending on the use of toolboxes, OOP etc.)open source packages available that replace expensive MATLAB toolboxessome extra syntactical “candy”

disadvantages:no GUI included(But you can for instance use QtOctave from http://qtoctave.wordpress.com )plotting (using Gnuplot) is not as comtortable as in MATLAB no GUI programming as in MATLABno Simulink equivalent

http://www.gnu.org/software/octave/

Page 21: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

21

More Alternatives

SciLab, SciCos, …free to useSciLab comes with a GUI (editor)SciCos allows graphical system building (→ like Simulink)

sagePython dialectall syntactical features and packages of Python usable

Python, NumPy, ...

...

http://www.scilab.org/http://www-rocq.inria.fr/scicos/

http://www.sagemath.org/

Page 22: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 23: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

23

General Transmission Model

channelpre-

codingde-

coding

physical layer physical layermedium

demo-dulation

modu-lation

PHYtransmission

sourcecoding

channel-coding

errordet./corr.

sourcedecoding

Page 24: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

24

Highpass vs. LowpassSignal Representation

passband (highpass) signal baseband (lowpass) signal

Due to the use of baseband representation wedon't have to care about the actual carrier frequency.Due to the use of baseband representation wedon't have to care about the actual carrier frequency.

channelpre-

codingde-

codingdemo-

dulationmodu-lation

Page 25: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

25

Complex Signals & Systems (1)

As we have seen, we can make use of baseband representation. This appliesfor signals as well as for systems. In addition we make use of the fact that the sine function and the cosine func-tion are orthogonal. This means we can transmit two different signals. Thosesignals signals are called in-phase u

I(t) and quadrature u

Q(t) component.

channel

passband system

Page 26: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

26

Complex Signals & Systems (2)

Instead of dealing with this form

we will use equivalent complex lowpass notation (which is more handy):

The channel (system + noise) is also described by complex functions/values.Thus we will use this general (complex) model:

Page 27: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 28: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

28

Digital Modulation – Phase-Shift Keying (PSK)

figures: http://en.wikipedia.org/wiki/Phase-shift_keying

Use the in-phase component and quadrature component to describe discretepoints in the complex plane. Such points are called symbols.

In PSK all symbols are equally spaced located on a circle. They can be disting-uished by their phase. The circle's radius defines the symbol (transmit) energyE

b and is equal for all symbols. Data bits are normally assigned to the symbols

using Gray Code.

BPSK (2-PSK) QPSK (4-PSK)Q Q

I I

0 1

00

01 11

10

Page 29: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

29

Digital Modulation – Quadrature Amplitude Modulation (QAM)

In QAM symbols are not only defined by their phase but also by their amplitude.(Remark: 4-QAM is equivalent to QPSK.)

figures: http://en.wikipedia.org/wiki/QAM

16-QAMQ

I

0010 0110 1110 1010

0011 0111 1111 1011

0001 0101 1101 1001

0000 0100 1100 1000

Page 30: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

30

PSK / QAM in MATLAB

<symbols> = pskmod(<data>, <PSK order>, <phase>, <codeType>);

<data> = psdekmod(<symbol>, <PSK order>, <phase>, <codeType>);

<symbols> = qammod(<data>, <QAM order>);

<data> = qamdemod(<symbol>, <QAM order>);

<data> … data to be modulated (scalar/vector/matrix)<PSK order> … # of different symbols (2 = BPSK, 4 = QPSK, …)<phase> … initial symbol rotation (null phase) – normally set to 0<codeType> … 'Bin' or 'Gray'

<data> … data to be modulated (scalar/vector/matrix)<QAM order> … # of different symbols

Page 31: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 32: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

32

Additive White Gaussian Noise (AWGN) Channel

channelpre-

codingde-

codingdemo-

dulationmodu-lation

Simplest transmission model that just assumes additive normally distributednoise that has a much larger bandwidth than the signal u(t) (and thus is trea-ted as white).

Page 33: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

33

AWGN Channel in MATLAB (1)

PSK = 2; % 2-PSK (BPSK)SNR = 5; % transmit signal-to-noise ratio (in dB)data = randint(1, 1, [0 PSK-1]); % produce a random number

% modulate the random data using Gray Code:symbol = pskmod(data, PSK, 0, 'Gray');

% simulate transmission over an AWGN channel:received_symbol = awgn(symbol, SNR);

% demodulation and symbol estimation:estimated_data = pskdemod(received_symbol, PSK, 0, 'Gray');

% compute bit errors:bit_errors = biterr(data, estimated_data);

fprintf('PSK:\n');fprintf(' %d --> %d\n', data, estimated_data);fprintf(' %d bit errors\n', bit_errors);

discrete model, linear, memoryless:

Page 34: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

34

AWGN Channel in MATLAB (2)

realizations = 16000; % 4000 trials per SNRSNRs = -10:20; % signal-to-noise ratios: -10dB … 20dBPSK = 2; % BPSKbit_errors = zeros(length(SNRs), 1); % BER with respect to SNR

for SNR_idx = 1:length(SNRs) cur_bit_errors = zeros(realizations, 1); for rlz = 1:realizations

data = randint(1, 1, [0 PSK-1]);symbol = pskmod(data, PSK, 0, 'Gray');received_symbol = awgn(symbol, SNRs(SNR_idx));estimated_data = pskdemod(received_symbol, PSK, 0, 'Gray');cur_bit_errors(rlz) = biterr(data, estimated_data);

end bit_errors(SNR_idx) = mean(cur_bit_errors);end

semilogy(SNRs , bit_errors); % plot with logarithmic y-axisgrid on; % show a gridxlabel('SNR [dB]'); ylabel('BER'); % label x- and y-axisprint -dpng psk_BER.png % save as plot PNG image

Page 35: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

35

AWGN Channel in MATLAB (3)

BE

R

1

10-4

10-3

10-2

10-1

10-5

-10 -5 0 5 10 15SNR [dB]

Page 36: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 37: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

37

Distance between Tx and Rx

path

loss

[dB

]Path Loss

1.4 – 1.9 some corridors/tunnels(→ wave guidance)

2 free space

3 furnished rooms(→ free space + multipath)

4 densely furnished rooms(→ NLOS, scattering,diffraction)

5 between different floors

figure: S. R. Saunders, Antennas and Propagation for Wireless Communication Systems, Wiley, 1999.

Path loss is the overall decrease of field strength due to the distance between Rxand Tx. Affected by: - antenna height

- frequency- atmospheric conditions- buildings- trees - ...

Page 38: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

38

Slow Fading

Distance between Tx and Rx

slow

fad

ing

S. R. Saunders, Antennas and Propagation for Wireless Communication Systems, Wiley, 1999.

Slow fading (shadowing, large-scale fading, log-normal fading) is the shadowingof signal due to large destructions. Affected by: - large buildings

- trees- hilly terrain- …

Slow fading changes more rapidlythan path loss and is a model fora multiplicative, slowly varyingrandom process.

It is empirically found that slowfading follows a nog-normal dis-tributed random process:

Page 39: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 40: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

40

Fast Fading

Distance between Tx and Rx

fast

fad

ing

figure: S. R. Saunders, Antennas and Propagation for Wireless Communication Systems, Wiley, 1999.

Fast fading (Rayleigh fading) is the result of constructive and destructive interfer-ence between multiple waves if the transmitter, the receiver or some scatterer in theenvironment is moving.

Moving Rx, Tx or environment causes not only instantaneous signal fluctuations(fading) but also cause a Doppler shift.

figures: http://en.wikipedia.org/wiki/Doppler_effect

figure: S. R. Saunders, Antennas and Propagation for Wireless Communication Systems, Wiley, 1999.

Rayleigh fading

Page 41: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

41

Two-Path Model

TxTx TxRx

path 2

path 1

amplitude

delay

path 1 path 2

No line-of-sight (LOS)!

Page 42: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

42

L-Path Model

Tx RX

No line-of-sight (LOS)!

Page 43: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

43

Rayleigh Fading

Since the amount of paths L can be very large we can apply the central limittheorem of statistics, i.e., the channel consists of normally distributed I- and Q-components.

Channel:

Magnitude:

Page 44: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

44

Rayleigh Distribution

figure: Wikipedia

Page 45: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

45

(SISO) Transmission over a Raleigh Fading Channel

Assumption: - Discrete memoryless linear channel, i.e.

-

- h[k] is known at the receiver (channel state information at Rx)

- PSK

-

Decoding: Rx has CSI → multiplication of the received signal with h*[k]

received signal

decoded signal

More detailsabout the memo-ryless model are explained in the

next section.

Page 46: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

46

Flat Fading Rayleigh Channel in MATLAB

PSK = 2; SNR = 5; data = randint(1, 1, [0 PSK-1]);

symbol = pskmod(data, PSK, 0, 'Gray');

% get a random complex channel coefficient % → see next part of the presentationchannel = (randn() + i*randn()) / sqrt(2);

% simulate transmission over an AWGN channel:received_symbol = awgn(channel*symbol, SNR);

% equalization:received_symbol = conj(channel) * received_symbol;

estimated_data = pskdemod(received_symbol, PSK, 0, 'Gray');bit_errors = biterr(data, estimated_data);

% … output …

Page 47: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

47

Two-Path Model with LOS

TxTx TxRxLOS

path 1

amplitude

delay

path 1 LOS

Page 48: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

48

L-Path Model with LOS

Tx RXLOS

Page 49: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

49

Rician Fading

Assuming a large number of scatterers and a line-of-sight we get a meanvalue at the receiver which is larger than zero.

Channel:

Magnitude:

Page 50: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

50

Rician Distribution

figure: Wikipedia

Page 51: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

51

Fading – Summary (1)

Source: S. R. Saunders, Antennas and Propagation for Wireless Communication Systems, Wiley, 1999.

Page 52: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

52

Fading – Summary (2)

A. Paulraj, R. Nabar, D. Gore, “Introduction to Space-Time Wireless Communications,” 2003.

Page 53: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 54: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

54

Frequency Selectivity – Time Domain

t0 T

frequency-selective channel(channel with memory)

2T

rece

ived

sig

nal

t0 T

frequency-flat fading channel(memoryless channel)

2Tre

ceiv

ed s

igna

l

Duration of received signal impulseis larger than one symbol duration T.

Duration of received signal impulse isshorter than one symbol duration T.

t0 T 2T

tran

smitt

edsy

mbo

l im

puls

e

Page 55: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

55

Frequency Selectivity – Frequency Domain

f

frequency-selective

Bc

W

chan

nel t

rans

fer

fct.

f

flat fading (frequency-non-selective)

Bc

W

chan

nel t

rans

fer

fct. … coherence

bandwidth

… signal bandwidth

Bc

W

Page 56: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

56

Frequency-Selective SISO Transmission

Discrete model:

Summation:

Vector notation:

Page 57: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

57

T T T T

+

s

n

y

Truncated Tapped Delay Line Model (SISO)

Page 58: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

58

Frequency-Flat Fading SISO Channel

We get the fat fading channel model if the channel has no memory, i.e., L=1.

“Vector” notation:

→ Flat fading means that we just have to multiply the symbol s with one complexrandom variable h. Thus the channel is described with just one compl. number.

→ MATLAB example is given on slide “Flat Fading Rayleigh Channel in MATLAB”.

T T T T

+

s

n

y

From nowon we will stick

to flat fading only.

Page 59: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 60: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

60

SIMO Channel Model – Freq.-Flat

… received signal

… channel between Tx and all Rx antennas

… transmitted signal

… zero mean circularly symmectric complex Gaussian (ZMCSCG)noise

Tx Rx

SIMO = single-input and multiple-output

Page 61: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

61

Selection Combining (SC)

Select the signal of that antenna that experiences the highest SNR.→ largest

Decoded symbol: Just a single antenna used!

Tx Rx

Page 62: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

62

Maximum Receive Ratio Combining (MRRC)

Add the signals from all antennas coherently.

Decoded symbol: All antennas are incorporated!

Tx Rx

Page 63: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

63

Equal Gain Combining (ECG)

Add the signals from all antennas as good as possible byshifting the phase of each received signal.

Decoded symbol: All antennas are incorporated!

In contrast to MRRC we justneed to know/adjust the phaseof the channel coefficients here.

Tx Rx

Page 64: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

64

SC, MRRC, and EGC Example

PSK = 2; SNR = -5;M_rx = 5; % No. of Rx antennas

data = randint(1, 1, [0 PSK-1]);s = pskmod(data, PSK, 0, 'Gray').';

h = (randn(M_rx, 1) + i*randn(M_rx, 1)) / sqrt(2); % SIMO channely = awgn(h*s, SNR);

[dummy idx] = max(abs(h)); % find channel with largest magnitudesc_estimated_s = conj(h(idx))*y(idx); % selection combining (SC)egc_estimated_s = exp(i*angle(h))'*y; % equal gain combining (EGC)mrrc_estimated_s = h'*y; % maximum receive ratio combining (MRRC)

sc_estimated_data = pskdemod(sc_estimated_s, PSK, 0, 'Gray');egc_estimated_data = pskdemod(egc_estimated_s, PSK, 0, 'Gray');mrrc_estimated_data = pskdemod(mrrc_estimated_s, PSK, 0, 'Gray');

sc_bit_errors = biterr(data, sc_estimated_data.');egc_bit_errors = biterr(data, egc_estimated_data.');mrrc_bit_errors = biterr(data, mrrc_estimated_data.');

Page 65: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

65

Simulation Results (SC, MRRC, EGC, SISO)

-10 -5 0 5 10

1

0.1

0.01

0.001

0.001

MRRCEGC

SCSISO

BE

R

SNR [dB]

Page 66: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 67: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

67

MISO Channel Model – Freq.-Flat

… received signal

… channel between all Tx antennas and Rx

… signal per transmit antenna

… ZMCSCG noise

RxTx

MISO = multiple-input and single-output

Page 68: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

68

Maximum Transmit Ratio Combining (MTRC)

Assume we want to send a single symbol.

Send several precoded versions of the same symbol, so that they add togetherat the receiver coherently.

Precoded transmit symbolsent from Tx antenna i:

Reception:

RxTx

Page 69: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

69

Alamouti's Scheme (1)

Transmission of two (clever encoded) symbols during twotime instants using two antennas

Tx Rx

Tx Rx

Transmission during first time instant:

Transmission during second time instant:

RxTx

Page 70: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

70

Alamouti's Scheme (2)

Tx Rx

Tx Rx

Now let's rearrange both received signal y[1] and y[2] (at the receiver):

The last trick is to diagonalize the equation:

Page 71: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

71

Alamouti Example

PSK = 2;SNR = -5;

data = randint(2, 1, [0 PSK-1]);s = pskmod(data, PSK, 0, 'Gray').';% one column per time instant:S = [s(1) conj(s(2)); s(2) -conj(s(1))];

h = (randn(1, 2) + i*randn(1, 2)) / sqrt(2); % MISO channel% simulate transmission of both time instants:y = awgn(h*S, SNR);

% Hermitian transpose of the effective channel:H_eff_herm = [conj(h(1)) -h(2); conj(h(2)) h(1)]; z = [y(1); conj(y(2))]; % rearranged receive vectorestimated_s = H_eff_herm*z;

estimated_data = pskdemod(estimated_s, PSK, 0, 'Gray');bit_errors = biterr(data, estimated_data.');

fprintf('%d bit errors\n', bit_errors);

Page 72: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

I. MATLAB III. The Radio Channel1. First Look at MATLAB 1. Path Loss, Slow Fading2. Syntax 2. Fast Fading3. Alternative Software 3. Frequency Selectivity

II. Communications Basics IV. Space-Time Communications1. Signals & Systems 1. SIMO2. Modulation 2. MISO3. AWGN Channel Model 3. MIMO

Outline

Page 73: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

73

MIMO Channel Model – Freq.-Flat

… received signal

… channel between all Tx/Rx antennas

… (a single) signal per transmit antenna

… ZMCSCG noise

(memoryless) channelbetween the m-th receiverand the n-th transmitter:

transmitter

receiver

Tx RxTx

simplified notationMIMO = multiple-input and multiple-output

Page 74: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

74

Zero Forcing (ZF)

For simplicity we assume that

and that H is invertable.

Decoded symbols:

matrix inversion

Tx RxTx

Page 75: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

75

MIMO Example

PSK = 8; SNR = -5;M = 5; % No of antennas at Rx and Tx

data = randint(M, 1, [0 PSK-1]);s = pskmod(data, PSK, 0, 'Gray').';

% get MIMO channel:H = ( randn(M, M) + i*randn(M, M) ) / sqrt(2);

% simulate AWGN channel:received_s = awgn(H*s, SNR);

% "Zero Forcing" (ZF):% (Has here the same effect as: inv(H)*received_s; )estimated_s = H \ received_s;

estimated_data = pskdemod(estimated_s, PSK, 0, 'Gray');bit_errors = biterr(data, estimated_data.');

fprintf('%d bit errors\n', bit_errors);

Page 76: MATLAB Models for PHY (for beginners) · I. MATLAB III. The Radio Channel 1. First Look at MATLAB 1. Path Loss, Slow Fading 2. Syntax 2. Fast Fading 3. Alternative Software 3. Frequency

76

Thank you andsee you next week!