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
- length : returns the number of elements in a row vector
length( [ 1 0 1 1 0 0 1 ] ) ⇒ ans = 7
- sum : returns the sum of all elements in an array
sum( [ 1 0 1 1 0 0 1 ] ) ⇒ ans = 4
- any : returns 1 if any element is non-zero
any( [ 0 0 0 0 0 ] ) ⇒ ans = 0
- isequal : returns 1 if two vectors are identical
isequal [ 1 0 1 1 ], [ 1 0 1 1 ] ) ⇒ ans = 1
- fliplr : returns a row vector in reverse order
fliplr( [ 1 0 1 1 ] ) ⇒ ans = 1 1 0 1
- 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
- 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
- dec2bin : returns a binary string from a decimal number
dec2bin(29,8) ⇒ ans = 00011101
- de2bi : returns a binary array from a decimal number
(CT)
de2bi(29,8,'left-msb') ⇒ ans = 0 0 0 1 1 1 0 1
- bi2de : returns a decimal number from a binary array
(CT)
bi2de( [ 1 1 1 0 1 ] ) ⇒ ans = 29
- double : returns ASCII codes (decimal) from a character string
double( 'ABC' ) ⇒ ans = 65 66 67
- char : returns a character string from ASCII codes (decimal)
char( [65 66 67] ) ⇒ ans = ABC
- bitxor : returns the bitwise xor of two values
bitxor( 5, 3 ) ⇒ ans = 6
- bitshift : returns a value shifted left by n bits
bitshift( 17, 1 ) ⇒ ans = 34
Galois Fields
- gf : defines a Galois Field GF(2)
(CT)
a = gf( [ 1 0 1 1 0 1 ] ) ⇒ a = 1 0 1 1 0 1
- 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
- .x : returns Galois Field elements as integers
(CT)
b = a.x ⇒ b = 1 0 1 1 0 1
- primpoly(N,'all') : returns all primitive polynomials of order N
(CT)
primpoly(4,'all') ⇒ ans = 19 25
- primpoly(N) : returns the default primitive polynomials of order N
(CT)
primpoly(4) ⇒ ans = 19
Error Control
- 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.
- 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
- 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