Skip to main content

Common mistakes using the 'pskmod' command in MATLAB

 

Sometimes, students incorrectly write code for phase shift keying modulation (PSK). They want to modulate the input bits. For example

 Method 1

N_Bits = 2520; % number of input bits
M = 4;
Phase = 0; % intial phase
input_bits = randi([0,1],N_Bits,1);
modData = pskmod(input_bits,M,Phase);


The above approach is correct once you're performing binary PSK or BPSK. The following code will work for higher-order modulation like 4-PSK, 8-PSK, 16-PSK, or 32-PSK.

 Method 2

N_Bits = 2520; % number of input bits
M = 4;

input_bits = randi([0,1],N_Bits,1);
data_temp = bi2de(reshape(input_bits,N_Bits/log2(M),log2(M)));
modData = pskmod(data_temp,M,Phase);


Another good approach is to generate random bits like this.

 Method 3

N_Symbols = 1000; % number of input symbols
M = 4;
Phase = 0; % intial phase
input_symbols = randi([0,(M-1)],N_Symbols,1);
modData = pskmod(input_symbols,M,Phase);


However, the above method could be more practical. It would be best to map input bits into symbols in most cases. So the second method is more important.

Contact Us

Name

Email *

Message *