Professional Documents
Culture Documents
clear all;
close all;
clc;
%-------------Parameters----------------
M = 16; % constellation size 16-QAM
k=log2(M);
c_real=1000; %number of different channel realizations
N=64; %IFFT/FFT length
L=16; %cyclic prefix length
l_path=L+1;
Eb_N0_dB=0:5:30;
Es_N0_dB = Eb_N0_dB + 10*log10(k);
Nb=k*c_real*N;
n_code=15;
k_code=7; % 11
for i = 1:length(Eb_N0_dB)
err(i)=0;
end
for i = 1:length(Eb_N0_dB)
%---------------Transmitter---------------
% Symbol Generation
sig_bit=rand(1,Nb,1)>0.5; % random 1's and 0's
% BCH coder
[code_bit, added] = encode(sig_bit, n_code, k_code,'Linear block');
% Interleaver
sig_inter = interleaving(l_row,k_column,sig_bit)
% mapping
sig_mapped=mapping(sig_inter,M); %mapping using Gray code
% group to n_real groupe of N symbols for doing ifft
sig_mapped = reshape(sig_mapped,N,c_real);
%----------------Noise-----------------
k_=sqrt(10);
s=sig_mapped/k_;
% AWGN noise
[row col] = size(sig_multipath); %find the size of sig_multipath, (col =
c_real)
noise = 1/sqrt(2)*[randn(row,col) + j*randn(row,col)]; % white guassian
noise, 0dB variance
x=10.^(-Es_N0_dB/20);
n=noise*x(i);
sig_afterchan = sig_multipath + noise;
% -------------RECEIVER--------------
% zero forcing
sig_zfe = sig_fft./hf;
% counting errors
err(i) = sum(abs(sig_demapped-sig_bit));
end