ReComm
Member level 2
dear friends,
using the help of regular search , i modified the next code, but kindly i don't know how to add noise to it. kindly advice
1. how to generate noise
2. plot BER vs EbNo
code
====
% QPSK OFDM
%===========
close all;
clear;
clc;
%Initilization
nBitPerSym = 52; % number of bits per OFDM symbol
nSym = 10^4; % number of symbols
nFFT = 64; % fft size
nDSC = 52; % number of data subcarriers
% Input Data Generation
data = rand(1,nBitPerSym*nSym*2) > 0.5; % random 1's and 0's
oddData = data(1:2:end);
evenData = data(2:2:end);
qpskModulated = sqrt(1/2)*(1i*(2*oddData-1)+(2*evenData-1)); %QPSK Mapping
% and normalization of energy to 1
qpskModulated_Reshape = reshape(qpskModulated,nBitPerSym,nSym).'; % grouping into multiple symbols
% Taking FFT
xt = (nFFT/sqrt(nDSC))*ifft(fftshift(qpskModulated_Reshape.')).';
% Appending cylic prefix
xt = [xt,[41:52]) xt];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Noise Insertion
yt=xt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Receiver
%==========
yt = yt,[13:64]); % removing cyclic prefix
% converting to frequency domain
yF = (sqrt(nDSC)/nFFT)*fftshift(fft(yt.')).';
%--------------Demodulation-----------------------------
%Threshold Detector
TX = reshape(yF.',nBitPerSym*nSym,1).';
detected_real = real(TX)>=0;
detected_img = imag(TX)>=0;
estimatedBits=reshape([detected_img;detected_real],1,[]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------------------------------------------
nErr = size(find([data - estimatedBits]),2); % couting the number of errors
Err_QPSK_OFDM = nErr/(nSym*nBitPerSym*2);
wait your reply,
using the help of regular search , i modified the next code, but kindly i don't know how to add noise to it. kindly advice
1. how to generate noise
2. plot BER vs EbNo
code
====
% QPSK OFDM
%===========
close all;
clear;
clc;
%Initilization
nBitPerSym = 52; % number of bits per OFDM symbol
nSym = 10^4; % number of symbols
nFFT = 64; % fft size
nDSC = 52; % number of data subcarriers
% Input Data Generation
data = rand(1,nBitPerSym*nSym*2) > 0.5; % random 1's and 0's
oddData = data(1:2:end);
evenData = data(2:2:end);
qpskModulated = sqrt(1/2)*(1i*(2*oddData-1)+(2*evenData-1)); %QPSK Mapping
% and normalization of energy to 1
qpskModulated_Reshape = reshape(qpskModulated,nBitPerSym,nSym).'; % grouping into multiple symbols
% Taking FFT
xt = (nFFT/sqrt(nDSC))*ifft(fftshift(qpskModulated_Reshape.')).';
% Appending cylic prefix
xt = [xt,[41:52]) xt];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Noise Insertion
yt=xt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Receiver
%==========
yt = yt,[13:64]); % removing cyclic prefix
% converting to frequency domain
yF = (sqrt(nDSC)/nFFT)*fftshift(fft(yt.')).';
%--------------Demodulation-----------------------------
%Threshold Detector
TX = reshape(yF.',nBitPerSym*nSym,1).';
detected_real = real(TX)>=0;
detected_img = imag(TX)>=0;
estimatedBits=reshape([detected_img;detected_real],1,[]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------------------------------------------
nErr = size(find([data - estimatedBits]),2); % couting the number of errors
Err_QPSK_OFDM = nErr/(nSym*nBitPerSym*2);
wait your reply,