0% found this document useful (0 votes)
54 views2 pages

Ofdm Sim

The document presents a MATLAB program that implements Orthogonal Frequency Division Multiplexing (OFDM) and evaluates the frame error rate (FER) against signal-to-noise ratio (SNR). It defines parameters for modulation, generates random data, and processes it through OFDM modulation and demodulation while adding noise. The results are plotted to visualize the relationship between SNR and error rates, including both FER and bit error rate (BER) for different modulation schemes.

Uploaded by

aaravbhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views2 pages

Ofdm Sim

The document presents a MATLAB program that implements Orthogonal Frequency Division Multiplexing (OFDM) and evaluates the frame error rate (FER) against signal-to-noise ratio (SNR). It defines parameters for modulation, generates random data, and processes it through OFDM modulation and demodulation while adding noise. The results are plotted to visualize the relationship between SNR and error rates, including both FER and bit error rate (BER) for different modulation schemes.

Uploaded by

aaravbhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Program to implement OFDM and evaluate frame error rate against SNR

CODE:
clear; clc;

% Parameters
N = 64; cp_len = 16; num_symbols = 10; mod_order = 4; num_frames = 1000;
snr_range = 0:2:20; mod_type = 'psk';

% Modula on
mod_fn = @(data) pskmod(data, mod_order);
demod_fn = @(data) pskdemod(data, mod_order);
if strcmpi(mod_type, 'qam')
mod_fn = @(data) qammod(data, mod_order, 'UnitAveragePower', true);
demod_fn = @(data) qamdemod(data, mod_order, 'UnitAveragePower', true);
end

ofdm_mod = @(data) sqrt(N)*i (reshape(data, N, []), N);

fer = zeros(size(snr_range)); ber = zeros(size(snr_range));

for snr_idx = 1:length(snr_range)


frame_errors = 0; bit_errors = 0; total_bits = 0;
for frame = 1:num_frames
data = randi([0 mod_order-1], N*num_symbols, 1);
ofdm_symbols = ofdm_mod(mod_fn(data));
tx_signal = [ofdm_symbols(end-cp_len+1:end, :); ofdm_symbols];
rx_signal = awgn(tx_signal(:), snr_range(snr_idx), 'measured');
rx_signal_reshaped = reshape(rx_signal, N+cp_len, []);
rx_data = (rx_signal_reshaped(cp_len+1:end, :), N)/sqrt(N);
demod_data = demod_fn(rx_data(:));
frame_errors = frame_errors + any(demod_data ~= data);
if mod_order == 4
bit_errors = bit_errors + sum(sum(de2bi(data,2) ~= de2bi(demod_data,2)));
total_bits = total_bits + numel(data)*2;
end
end
fer(snr_idx) = frame_errors / num_frames;
if mod_order == 4, ber(snr_idx) = bit_errors / total_bits; end
end

% Plot
figure;
semilogy(snr_range, fer, 'b-o', 'LineWidth', 2); hold on;
if mod_order == 4, semilogy(snr_range, ber, 'r--s', 'LineWidth', 2); end
grid on;
xlabel('SNR (dB)'); ylabel('Error Rate');
tle(['OFDM Performance: ', num2str(mod_order), '-', upper(mod_type)]);
legend('FER', 'BER');

OUTPUT:

You might also like