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

Theoretical BER vs SNR for binary ASK, FSK, and PSK with MATLAB Code + Simulator

📘 Overview & Theory 🧮 MATLAB Codes 📚 Further Reading Bit Error Rate (BER) Equations BER formulas for ASK, FSK, and PSK modulation schemes. ASK BER = 0.5 × erfc(0.5 × √SNR) FSK BER = 0.5 × erfc(√(SNR / 2)) PSK BER = 0.5 × erfc(√SNR) Theoretical BER vs SNR for Amplitude Shift Keying (ASK) The theoretical Bit Error Rate (BER) for binary ASK depends on how binary bits are mapped to signal amplitudes. For typical cases: If bits are mapped to 1 and -1, the BER is: BER = Q(√(2 × SNR)) If bits are mapped to 0 and 1, the BER becomes: BER = Q(√(SNR / 2)) Where: Q(x) is the Q-function: Q(x) = 0.5 × erfc(x / √2) SNR : Signal-to-Noise Ratio N₀ : Noise Power Spectral Density Understanding the Q-F...

Simulation of ASK, FSK, and PSK using MATLAB Simulink (with Online Simulator)

📘 Overview 🧮 How to use MATLAB Simulink 🧮 Simulation of ASK using MATLAB Simulink 🧮 Simulation of FSK using MATLAB Simulink 🧮 Simulation of PSK using MATLAB Simulink 🧮 Simulator for ASK, FSK, and PSK 🧮 Digital Signal Processing Simulator 📚 Further Reading ASK, FSK & PSK HomePage MATLAB Simulation Simulation of Amplitude Shift Keying (ASK) using MATLAB Simulink In Simulink, we pick different components/elements from MATLAB Simulink Library. Then we connect the components and perform a particular operation. Result A sine wave source, a pulse generator, a product block, a mux, and a scope are shown in the diagram above. The pulse generator generates the '1' and '0' bit sequences. Sine wave sources produce a specific amplitude and frequency. The scope displays the modulated signal as well as the original bit sequence created by the pulse generator. Mux i...

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

Power Spectral Density Calculation Using FFT in MATLAB

📘 📘 Overview 🧮 🧮 Steps to calculate 💻 🧮 MATLAB Codes 📚 📚 Further Reading Power spectral density (PSD) tells us how the power of a signal is distributed across different frequency components, whereas Fourier Magnitude gives you the amplitude (or strength) of each frequency component in the signal. Steps to calculate the PSD of a signal Firstly, calculate the fast Fourier transform (FFT) of a signal. Then, calculate the Fourier magnitude (absolute value) of the signal. Square the Fourier magnitude to get the power spectrum. To calculate the Power Spectral Density (PSD), divide the squared magnitude by the product of the sampling frequency (fs) and the total number of samples (N). Formula: PSD = |FFT|^2 / (fs * N) Sampling frequency (fs): The rate at which the continuous-time signal is sampled (in Hz). ...

Online Simulator for ASK, FSK, and PSK

Try our new Digital Signal Processing Simulator!   •   Interactive ASK, FSK, and BPSK tools updated for 2025. Start Now Interactive Modulation Simulators Visualize binary modulation techniques (ASK, FSK, BPSK) in real-time with adjustable carrier and sampling parameters. 📡 ASK Simulator 📶 FSK Simulator 🎚️ BPSK Simulator 📚 More Topics ASK Modulator FSK Modulator BPSK Modulator More Topics Simulator for Binary ASK Modulation Digital Message Bits Carrier Freq (Hz) Sampling Rate (...

MATLAB Codes for Various types of beamforming | Beam Steering, Digital...

📘 How Beamforming Improves SNR 🧮 MATLAB Code 📚 Further Reading 📂 Other Topics on Beamforming in MATLAB ... MIMO / Massive MIMO Beamforming Techniques Beamforming Techniques MATLAB Codes for Beamforming... How Beamforming Improves SNR The mathematical [↗] and theoretical aspects of beamforming [↗] have already been covered. We'll talk about coding in MATLAB in this tutorial so that you may generate results for different beamforming approaches. Let's go right to the content of the article. In analog beamforming, certain codebooks are employed on the TX and RX sides to select the best beam pairs. Because of their beamforming gains, communication created through the strongest beams from both the TX and RX side enhances spectrum efficiency. Additionally, beamforming gain directly impacts SNR improvement. [Read more about Beamforming and How it improves SNR] Wireless...

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

Constellation Diagrams: ASK, FSK, and PSK Comprehensive guide to signal space representation, including interactive simulators and MATLAB implementations. 📘 Overview 🧮 Simulator ⚖️ Theory 📚 Resources Definitions Constellation Tool Key Points MATLAB Code 📂 Other Topics: M-ary PSK & QAM Diagrams ▼ 🧮 Simulator for M-ary PSK Constellation 🧮 Simulator for M-ary QAM Constellation 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 on...

Linear Predictive Coding (LPC) in Speech Processing

Linear Predictive Coding (LPC) in Speech Signal Processing What is LPC? Linear Predictive Coding (LPC) is a method that represents a speech signal using a small number of parameters. It models the speech signal as the output of a linear filter excited by a source (voice or noise). LPC is widely used in speech compression, speech synthesis, coding, and recognition. 1. Core Idea of LPC LPC assumes that the current speech sample can be approximated by a linear combination of past samples: x[n] ≈ a₁ x[n−1] + a₂ x[n−2] + ... + aₚ x[n−p] The coefficients a₁, a₂, ..., aₚ are chosen to minimize the prediction error . 2. Why This Works for Speech The human vocal tract behaves like an all-pole acoustic filter . Thus speech can be approximated by the model: x[n] = − Σ (aâ‚– x[n−k]) + G e[n] Where: aâ‚– = LPC coefficients (vocal tract shape) e[n]...