EE4253 Digital Communications Department of Electrical and Computer Engineering - University of New Brunswick, Fredericton, NB, Canada

MATLAB Reference for Digital Communications

This page summarizes some MATLAB operations that may be useful for digital communications.

Functions specific to the Communications Toolbox are shown highlighted as (CT).

For help on any MATLAB command, type > help command

Binary and Vector Operations

1. length : returns the number of elements in a row vector
length( [ 1 0 1 1 0 0 1 ] ) ⇒ ans = 7

2. sum : returns the sum of all elements in an array
sum( [ 1 0 1 1 0 0 1 ] ) ⇒ ans = 4

3. any : returns 1 if any element is non-zero
any( [ 0 0 0 0 0 ] ) ⇒ ans = 0

4. isequal : returns 1 if two vectors are identical
isequal [ 1 0 1 1 ], [ 1 0 1 1 ] ) ⇒ ans = 1

5. fliplr : returns a row vector in reverse order
fliplr( [ 1 0 1 1 ] ) ⇒ ans = 1 1 0 1

6. zeros : returns an array filled with zeros
[ 1 , zeros(1,14), 1 ] ⇒ ans = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

7. ones : returns an array filled with ones
[ 0, ones(1,14), 0 ] ⇒ ans = 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0

8. dec2bin : returns a binary string from a decimal number
dec2bin(29,8) ⇒ ans = 00011101

9. de2bi : returns a binary array from a decimal number (CT)
de2bi(29,8,'left-msb') ⇒ ans = 0 0 0 1 1 1 0 1

10. bi2de : returns a decimal number from a binary array (CT)
bi2de( [ 1 1 1 0 1 ] ) ⇒ ans = 29

11. double : returns ASCII codes (decimal) from a character string
double( 'ABC' ) ⇒ ans = 65 66 67

12. char : returns a character string from ASCII codes (decimal)
char( [65 66 67] ) ⇒ ans = ABC

13. bitxor : returns the bitwise xor of two values
bitxor( 5, 3 ) ⇒ ans = 6

14. bitshift : returns a value shifted left by n bits
bitshift( 17, 1 ) ⇒ ans = 34

Galois Fields

1. gf : defines a Galois Field GF(2) (CT)
a = gf( [ 1 0 1 1 0 1 ] ) ⇒ a = 1 0 1 1 0 1

2. gf : defines a Galois Field GF(2^N) with the default primitive polynomial` (CT)
a = gf( [ 1 0 1 1 0 1 ], 3 ) ⇒ a = 1 0 1 1 0 1

3. .x : returns Galois Field elements as integers (CT)
b = a.x ⇒ b = 1 0 1 1 0 1

4. primpoly(N,'all') : returns all primitive polynomials of order N (CT)
primpoly(4,'all') ⇒ ans = 19 25

5. primpoly(N) : returns the default primitive polynomials of order N (CT)
primpoly(4) ⇒ ans = 19

Error Control

1. hammgen(N) : returns the check (and generating) matrix for a default primitive polynomials of order N (CT)
[H,G] = primpoly(3) ⇒ ans = the corresponding 3 x 7 check matrix and 4 x 7 generating matrix.

2. hammgen(N,pol) : returns the check (and generating) matrix for a supplied primitive polynomial of order N (CT)
primpoly(3,[1 1 0 1]) ⇒ ans = the corresponding 3 x 7 check matrix

3. gen2par(G) : returns the check matrix for a supplied generator matrix (and vice versa) (CT)
gen2par(G) ⇒ ans = the corresponding check matrix H for the generator matrix G

 Mon May 20 01:50:03 ADT 2013 Last Updated: 23 APR 2013 Richard Tervo [ tervo@unb.ca ] Back to the course homepage...