clear all;
close all;
%=============== Some standard Hyperlan Params ==================
T = 50e-9; % System sampling period
fs = 1/T; % System sampling freq = 20MHz
Tcp = 16*T; % CP period
Tu = 64*T; % Useful symbol period
Ts = Tu+Tcp; % OFDM Symbol period 80 samples
delta_f = 0.3125e6; % Frequency spacing
FFTLen = 64; % Length of FFT.
CPLen = 16; % Length of Cyclic Prefix
M = 4; % Bits encoded in a QAM symbol.
Ns = 10; % Number of Symbols/Carrier
%F = 3; % Order of the filter
w = ones(FFTLen, 1); % Filter coefficients, initialised to zero order 10 by default.
SNRdB = 0; % SNR of AWGN in channel in dB
store_input = zeros(Ns, FFTLen*M); % Used to calculate BER at the end.
store_output = zeros(Ns, FFTLen*M);
store_error = zeros(Ns, FFTLen);
%=================== Simulation ===============================
for sym=1:Ns
%----------- Data genration ------------------
input = rand(1,FFTLen*M) > 0.5; %transmits one symbol
store_input(sym,:) = input;
%----------- Transmit Data -------------------
[signal_tx, input_symbols] = transmitter(input, FFTLen, CPLen, M);
%----------- Channel the data ----------------
signal_rx = channel(signal_tx, SNRdB);
%-------------- Receiver ---------------------
[signal_recovered, w, error_sym] = ...
receiver_lmmse(signal_tx, signal_rx, input_symbols, FFTLen, CPLen, M, w, SNRdB);
store_output(sym,:) = signal_recovered;
store_error(sym,:) = error_sym.';
end
%=============== Simulation End ============================
%==================== BER Calculation =========================
errors = abs(store_input - store_output);
num_errors = sum(sum(errors));
BER = num_errors/(FFTLen*M*Ns)
%=================== Plot Equlaizer Convergence ==================
figure(10);
error_samples = reshape(store_error.',1,(FFTLen)*Ns);
semilogy(abs(error_samples.^2)), ...
title('Zero Force Equalizer Error Over 10 Symbols') ...
,ylabel('Error Squared'), xlabel('OFDM Symbol');
%==================== END FILE ===================================