Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] how to add noise iinto QPSK OFDM code --urgent

Status
Not open for further replies.

ReComm

Member level 2
Joined
Aug 26, 2010
Messages
43
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Egypt
Activity points
1,627
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,
 

is the group receive my posts? Kindly help.
 

Define:

SNRdB=[0:30];%Define a range of SNR in dB
SNRLin=10.^(SNRdB./10);%Convert SNR to linear scale
.
.
.
for ii=1:length(SNRLin)%For each SNR

n=(1/sqrt(2))*(randn(1,1)+1i*randn(1,1));%generate a Guassian noise with zero mean and unit variance
.
.
.
yt=xt+(1/sqrt(SNRLin))*n;%add the noise to the transmitted signal.

.
.
.
Err(ii)=...%Compute the number of errors for each SNR
end
.
.
semilogy(SNRdB,Err_QPSK_OFDM)
 
  • Like
Reactions: ReComm

    ReComm

    Points: 2
    Helpful Answer Positive Rating
Thanks David83 for your reply,

But kindly why you use 1/sqrt(2) in n generation? and is this value changed by modulation scheme?
Also why you multiply n by (1/sqrt(SNRLin)) in adding noise to transmitted signal?

Thanks and wait your reply,
 

for 1/sqrt(2): because randn in MATLAB generates a Gaussian random variable with zero mean and unit variance. The term randn()+1i*randn() will be zero mean and variance of 2. But (1/sqrt(2))*(randn(1,1)+1i*randn(1,1)) will be zero mean and unit variance, which most convenient.

For (1/sqrt(SNRLin)): because in the received signal yt=xt+(1/sqrt(SNRLin))*n the average SNR will be: 1/(1/SNRLin)=SNRLin. In other words, we add a noise term to make the average SNR equals SNRLin. I know it sounds confusing, but think a little about it.
 
  • Like
Reactions: ReComm

    ReComm

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top