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.

People are good at skipping over material they already know!

View Related Topics to







Contact Us

Name

Email *

Message *

Popular Posts

BER vs SNR for M-ary QAM, M-ary PSK, QPSK, BPSK, ...(MATLAB Code + Simulator)

Bit Error Rate (BER) & SNR Guide Analyze communication system performance with our interactive simulators and MATLAB tools. 📘 Theory 🧮 Simulators 💻 MATLAB Code 📚 Resources BER Definition SNR Formula BER Calculator MATLAB Comparison 📂 Explore M-ary QAM, PSK, and QPSK Topics ▼ 🧮 Constellation Simulator: M-ary QAM 🧮 Constellation Simulator: M-ary PSK 🧮 BER calculation for ASK, FSK, and PSK 🧮 Approaches to BER vs SNR What is Bit Error Rate (BER)? The BER indicates how many corrupted bits are received compared to the total number of bits sent. It is the primary figure of merit for a...

ASK, FSK, and PSK (with MATLAB + Online Simulator)

📘 ASK Theory 📘 FSK Theory 📘 PSK Theory 📊 Comparison 🧮 MATLAB Codes 🎮 Simulator ASK or OFF ON Keying ASK is a simple (less complex) Digital Modulation Scheme where we vary the modulation signal's amplitude or voltage by the message signal's amplitude or voltage. We select two levels (two different voltage levels) for transmitting modulated message signals. Example: "+5 Volt" (upper level) and "0 Volt" (lower level). To transmit binary bit "1", the transmitter sends "+5 Volts", and for bit "0", it sends no power. The receiver uses filters to detect whether a binary "1" or "0" was transmitted. Fig 1: Output of ASK, FSK, and PSK modulation using MATLAB for a data stream "1 1 0 0 1 0 1 0" ( Get MATLAB Code ) ...

Calculation of SNR from FFT bins in MATLAB

📘 Overview 💻 FFT Bin Method 💻 Kaiser Window 📚 Further Reading SNR Estimation Overview In digital signal processing, estimating the Signal-to-Noise Ratio (SNR) accurately is crucial. Below, we demonstrate how to calculate SNR from periodogram and FFT bins using the Kaiser Window . The beta (β) parameter is the key—it allows you to control the trade-off between main-lobe width and side-lobe levels for precise spectral analysis. 1 Define Sampling rate and Time vector 2 Compute FFT and Periodogram PSD 3 Identify Signal Bin and Frequency resolution 4 Segment Signal Power from Noise floor 5 Logarithmic calculation of SNR in dB Method 1: Estimation from FFT Bins This approach uses a Hamming window to estimate SNR directly from the spectral bins. MATLAB Source Code Copy Code clc...

MATLAB Code for ASK, FSK, and PSK (with Online Simulator)

📘 Overview & Theory 🧮 MATLAB Code for ASK 🧮 MATLAB Code for FSK 🧮 MATLAB Code for PSK 🧮 Simulator for binary ASK, FSK, and PSK Modulations 📚 Further Reading ASK, FSK & PSK HomePage MATLAB Code MATLAB Code for ASK Modulation and Demodulation % The code is written by SalimWireless.Com % Clear previous data and plots clc; clear all; close all; % Parameters Tb = 1; % Bit duration (s) fc = 10; % Carrier frequency (Hz) N_bits = 10; % Number of bits Fs = 100 * fc; % Sampling frequency (ensure at least 2*fc, more for better representation) Ts = 1/Fs; % Sampling interval samples_per_bit = Fs * Tb; % Number of samples per bit duration % Generate random binary data rng(10); % Set random seed for reproducibility binary_data = randi([0, 1], 1, N_bits); % Generate random binary data (0 or 1) % Initialize arrays for continuous signals t_overall = 0:Ts:(N_bits...

Online Simulator for ASK, FSK, and PSK

Try our new Digital Signal Processing Simulator!   Start Simulator for binary ASK Modulation Message Bits (e.g. 1,0,1,0) Carrier Frequency (Hz) Sampling Frequency (Hz) Run Simulation Simulator for binary FSK Modulation Input Bits (e.g. 1,0,1,0) Freq for '1' (Hz) Freq for '0' (Hz) Sampling Rate (Hz) Visualize FSK Signal Simulator for BPSK Modulation ...

Constellation Diagrams of ASK, PSK, and FSK with MATLAB Code + Simulator

📘 Overview of Energy per Bit (Eb / N0) 🧮 Online Simulator for constellation diagrams of ASK, FSK, and PSK 🧮 Theory behind Constellation Diagrams of ASK, FSK, and PSK 🧮 MATLAB Codes for Constellation Diagrams of ASK, FSK, and PSK 📚 Further Reading 📂 Other Topics on Constellation Diagrams of ASK, PSK, and FSK ... 🧮 Simulator for constellation diagrams of m-ary PSK 🧮 Simulator for constellation diagrams of m-ary QAM BASK (Binary ASK) Modulation: Transmits one of two signals: 0 or -√Eb, where Eb​ is the energy per bit. These signals represent binary 0 and 1.    BFSK (Binary FSK) Modulation: Transmits one of two signals: +√Eb​ ( On the y-axis, the phase shift of 90 degrees with respect to the x-axis, which is also termed phase offset ) or √Eb (on x-axis), where Eb​ is the energy per bit. These signals represent binary 0 and 1.  BPSK (Binary PSK) Modulation: Transmits one of two signals...

LDPC Encoding and Decoding Techniques

📘 Overview & Theory 🧮 LDPC Encoding Techniques 🧮 LDPC Decoding Techniques 📚 Further Reading 'LDPC' is the abbreviation for 'low density parity check'. LDPC code H matrix contains very few amount of 1's and mostly zeroes. LDPC codes are error correcting code. Using LDPC codes, channel capacities that are close to the theoretical Shannon limit can be achieved.  Low density parity check (LDPC) codes are linear error-correcting block code suitable for error correction in a large block sizes transmitted via very noisy channel. Applications requiring highly reliable information transport over bandwidth restrictions in the presence of noise are increasingly using LDPC codes. 1. LDPC Encoding Technique The proper form of H matrix is derived from the given matrix by doing multiple row operations as shown above. In the above, H is parity check matrix and G is generator matrix. If you consider matrix H as [-P' | I] then matrix G will b...

Comparing Baseband and Passband Implementations of ASK, FSK, and PSK

📘 Overview 🧮 Baseband and Passband Implementations of ASK, FSK, and PSK 🧮 Difference betwen baseband and passband 📚 Further Reading 📂 Other Topics on Baseband and Passband ... 🧮 Baseband modulation techniques 🧮 Passband modulation techniques   Baseband modulation techniques are methods used to encode information signals onto a baseband signal (a signal with frequencies close to zero). Passband techniques shift these signals to higher carrier frequencies for transmission. Here are the common implementations: Amplitude Shift Keying (ASK) [↗] : In ASK, the amplitude of the signal is varied to represent different symbols. Binary ASK (BASK) is a common implementation where two different amplitudes represent binary values (0 and 1). ASK is simple but susceptible to noise. ASK Baseband (Digital Bits) ASK Passband (Modulated Carrier)     Fig 1:  ASK Passband Modulation (...