Skip to main content

Data Rate in OFDM using MATLAB



MATLAB Code

% Example: OFDM with Passband Transmission, Data Rate Calculation, and Signal Visualization
clear;
clc;

% 1. Define bitstream (as a string of bits)
bitstream = '1011000110110001'; % Example bitstream

% 2. Parameters
numSymbols = length(bitstream) / 2; % Each QPSK symbol maps to 2 bits
numSubcarriers = 4; % Number of subcarriers
nSymbolsPerOFDM = numSubcarriers; % Number of symbols per OFDM symbol (each subcarrier gets 1 symbol)

% Carrier Frequency (Passband)
f_c = 2e6; % Carrier frequency (in Hz) for passband transmission, e.g., 2 MHz

% Sampling Frequency
fs = 20e6; % Sampling frequency (in Hz), e.g., 20 MHz

% Symbol duration (inverse of symbol rate)
symbolDuration = numSubcarriers / fs; % Duration of one OFDM symbol

% 3. Map bits to QPSK symbols (2 bits -> 1 symbol)
qpskSymbols = zeros(1, numSymbols);
for i = 1:numSymbols
bits = bitstream(2*i-1:2*i); % Get 2 bits for each symbol
if strcmp(bits, '00')
qpskSymbols(i) = 1 + 1i;
elseif strcmp(bits, '01')
qpskSymbols(i) = 1 - 1i;
elseif strcmp(bits, '10')
qpskSymbols(i) = -1 + 1i;
elseif strcmp(bits, '11')
qpskSymbols(i) = -1 - 1i;
end
end

% 4. Reshape the symbols into groups of 4 (each group corresponds to one OFDM symbol)
ofdmSymbols = reshape(qpskSymbols, numSubcarriers, []);

% 5. Apply IFFT (Inverse Fast Fourier Transform) to convert from frequency domain to time domain
timeDomainSymbols = ifft(ofdmSymbols, numSubcarriers);

% 6. Add Cyclic Prefix (CP) - Take the last N samples of each symbol and prepend them
cyclicPrefixLength = 1; % Length of the cyclic prefix (for simplicity, we use 1)
ofdmWithCP = [timeDomainSymbols(end-cyclicPrefixLength+1:end, :); timeDomainSymbols];

% 7. Serialize (Concatenate) the OFDM symbols with CP
transmittedSignal_baseband = ofdmWithCP(:)'; % Concatenate all symbols with CP into one continuous signal

% 8. Passband Modulation (Shift to Passband using Carrier)
t_baseband = (0:length(transmittedSignal_baseband)-1) / fs; % Time vector for baseband signal
I = real(transmittedSignal_baseband) .* cos(2*pi*f_c*t_baseband); % In-phase component
Q = imag(transmittedSignal_baseband) .* sin(2*pi*f_c*t_baseband); % Quadrature component
transmittedSignal_passband = I + Q; % Passband signal

% 9. Time Scaling for Better Visualization
% For visualization purposes, we'll rescale the time axis to match the proper timing
t_upsampled = linspace(0, (length(transmittedSignal_baseband)-1)/fs, length(transmittedSignal_baseband));
t_passband = linspace(0, (length(transmittedSignal_baseband)-1)/fs, length(transmittedSignal_passband));

% 10. Display the results
figure;

% Plot the original message signal (bitstream converted to QPSK symbols)
subplot(3,1,1);
stem(real(transmittedSignal_baseband), 'filled', 'MarkerSize', 2);
hold on;
stem(imag(transmittedSignal_baseband), 'filled', 'MarkerSize', 2);
title('Original Message Signal (Baseband QPSK)');
xlabel('Time (s)');
ylabel('Amplitude');
legend('In-phase', 'Quadrature');
grid on;

% Plot the baseband modulated signal
subplot(3,1,2);
plot(real(transmittedSignal_baseband), 'b');
hold on;
plot(imag(transmittedSignal_baseband), 'r');
title('Baseband Modulated Signal (QPSK)');
xlabel('Time (s)');
ylabel('Amplitude');
legend('In-phase', 'Quadrature');
grid on;

% Plot the passband signal (shifted to carrier frequency)
subplot(3,1,3);
plot(t_passband, transmittedSignal_passband, 'k');
title('Passband OFDM Signal (with Carrier Modulation)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

% 11. Data rate calculation
bitsPerSymbol = 2; % QPSK uses 2 bits per symbol
symbolRate = 1 / symbolDuration; % Symbol rate (in symbols per second)

% Data rate in bits per second (bps)
dataRate = numSubcarriers * bitsPerSymbol * symbolRate;

% Convert to Mbps (megabits per second)
dataRateMbps = dataRate / 1e6;
disp(['Data Rate: ', num2str(dataRateMbps), ' Mbps']);


Output

Data Rate: 40 Mbps


 

People are good at skipping over material they already know!

View Related Topics to







Contact Us

Name

Email *

Message *

Popular Posts

Channel Impulse Response (CIR)

📘 Overview & Theory 📘 How CIR Affects the Signal 🧮 Online Channel Impulse Response Simulator 🧮 MATLAB Codes 📚 Further Reading What is the Channel Impulse Response (CIR)? The Channel Impulse Response (CIR) is a concept primarily used in the field of telecommunications and signal processing. It provides information about how a communication channel responds to an impulse signal. It describes the behavior of a communication channel in response to an impulse signal. In signal processing, an impulse signal has zero amplitude at all other times and amplitude ∞ at time 0 for the signal. Using a Dirac Delta function, we can approximate this. Fig: Dirac Delta Function The result of this calculation is that all frequencies are responded to equally by δ(t) . This is crucial since we never know which frequenci...

Gaussian minimum shift keying (GMSK)

📘 Overview & Theory 🧮 Simulator for GMSK 🧮 MSK and GMSK: Understanding the Relationship 🧮 MATLAB Code for GMSK 📚 Simulation Results for GMSK 📚 Q & A and Summary 📚 Further Reading Dive into the fascinating world of GMSK modulation, where continuous phase modulation and spectral efficiency come together for robust communication systems! Core Process of GMSK Modulation Phase Accumulation (Integration of Filtered Signal) After applying Gaussian filtering to the Non-Return-to-Zero (NRZ) signal, we integrate the smoothed NRZ signal over time to produce a continuous phase signal: θ(t) = ∫ 0 t m filtered (Ī„) dĪ„ This integration is crucial for avoiding abrupt phase transitions, ensuring smooth and continuous phase changes. Phase Modulation The next step involves using the phase signal to modulate a...

BER vs SNR for M-ary QAM, M-ary PSK, QPSK, BPSK, ...

📘 Overview of BER and SNR 🧮 Online Simulator for BER calculation of m-ary QAM and m-ary PSK 🧮 MATLAB Code for BER calculation of M-ary QAM, M-ary PSK, QPSK, BPSK, ... 📚 Further Reading 📂 View Other Topics on M-ary QAM, M-ary PSK, QPSK ... 🧮 Online Simulator for Constellation Diagram of m-ary QAM 🧮 Online Simulator for Constellation Diagram of m-ary PSK 🧮 MATLAB Code for BER calculation of ASK, FSK, and PSK 🧮 MATLAB Code for BER calculation of Alamouti Scheme 🧮 Different approaches to calculate BER vs SNR What is Bit Error Rate (BER)? The abbreviation BER stands for Bit Error Rate, which indicates how many corrupted bits are received (after the demodulation process) compared to the total number of bits sent in a communication process. BER = (number of bits received in error) / (total number of tran...

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 ...

Wireless Communication Interview Questions | Page 2

Wireless Communication Interview Questions Page 1 | Page 2| Page 3| Page 4| Page 5   Digital Communication (Modulation Techniques, etc.) Importance of digital communication in competitive exams and core industries Q. What is coherence bandwidth? A. See the answer Q. What is flat fading and slow fading? A. See the answer . Q. What is a constellation diagram? Q. One application of QAM A. 802.11 (Wi-Fi) Q. Can you draw a constellation diagram of 4QPSK, BPSK, 16 QAM, etc. A.  Click here Q. Which modulation technique will you choose when the channel is extremely noisy, BPSK or 16 QAM? A. BPSK. PSK is less sensitive to noise as compared to Amplitude Modulation. We know QAM is a combination of Amplitude Modulation and PSK. Go through the chapter on  "Modulation Techniques" . Q.  Real-life application of QPSK modulation and demodulation Q. What is  OFDM?  Why do we use it? Q. What is the Cyclic prefix in OFDM?   Q. In a c...

Q-function in BER vs SNR Calculation

Q-function in BER vs. SNR Calculation In the context of Bit Error Rate (BER) and Signal-to-Noise Ratio (SNR) calculations, the Q-function plays a significant role, especially in digital communications and signal processing . What is the Q-function? The Q-function is a mathematical function that represents the tail probability of the standard normal distribution. Specifically, it is defined as: Q(x) = (1 / sqrt(2Ī€)) ∫ₓ∞ e^(-t² / 2) dt In simpler terms, the Q-function gives the probability that a standard normal random variable exceeds a value x . This is closely related to the complementary cumulative distribution function of the normal distribution. The Role of the Q-function in BER vs. SNR The Q-function is widely used in the calculation of the Bit Error Rate (BER) in communication systems, particularly in systems like Binary Phase Shift Ke...

Constellation Diagrams of ASK, PSK, and FSK

📘 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...

MATLAB code for Pulse Code Modulation (PCM) and Demodulation

📘 Overview & Theory 🧮 Quantization in Pulse Code Modulation (PCM) 🧮 MATLAB Code for Pulse Code Modulation (PCM) 🧮 MATLAB Code for Pulse Amplitude Modulation and Demodulation of Digital data 🧮 Other Pulse Modulation Techniques (e.g., PWM, PPM, DM, and PCM) 📚 Further Reading MATLAB Code for Pulse Code Modulation clc; close all; clear all; fm=input('Enter the message frequency (in Hz): '); fs=input('Enter the sampling frequency (in Hz): '); L=input('Enter the number of the quantization levels: '); n = log2(L); t=0:1/fs:1; % fs nuber of samples have tobe selected s=8*sin(2*pi*fm*t); subplot(3,1,1); t=0:1/(length(s)-1):1; plot(t,s); title('Analog Signal'); ylabel('Amplitude--->'); xlabel('Time--->'); subplot(3,1,2); stem(t,s);grid on; title('Sampled Sinal'); ylabel('Amplitude--->'); xlabel('Time--->'); % Quantization Process vmax=8; vmin=-vmax; %to quanti...