mjh
Newbie level 1
qam ber
Hi,
I am simulating a QAM modulation for 2,4,16 & 64 QAM and want to produce the BER v EbNo graph for a noisy signal in order to compare to the theoretical value I have. i know this is relatively easy, but I'm not sure how to/the best way to do this. The basis of my code is below, so if someone could help with the relevant section (or be able to send me any QAM code you have..) i would greatly appreciate it, thanks... mjh
% Variables & parameters:
global M % Sets M as a global variable
global ynoise
bps=log2(M) % No. of bits per symbol
n = 30000; % No. of bits to process
Fd=1;Fs=1; % Sampling freq (input;output)
nsamp=1; % Oversampling rate
J= sqrt(-1); % To represent imag component J
% Generate signal with noise:
x = randint(n,1); % To create a random binary stream
xsym = bi2de(reshape(x,bps,length(x)/bps).','left-msb'); % Convert the bits in x into k-bit symbols.
y = dmodce(xsym,Fd,Fs, 'qask',M); % Modulate for M-QAM
ytx = y; % Transmitted signal
% Signal over AWGN channel
EbNo = 10; % NB: in dB
snr = EbNo + 10*log10(bps) - 10*log10(nsamp);
ynoise = awgn(ytx,snr,'measured');
%ynoise = awgn(y,(M-1)); % Transmit signal through an AWGN channel.
yrx = ynoise; % Received Signal
% BER:
figure; % To open new figure
% Theoretical BER curve, Pe...
xfunc = sqrt((3/(n^2-1)*EbNo)); % Set variable 'xfunc' = sqrt(2*) to use in Pe equation..
Pe = (2*(1-(1/n))*erfc(xfunc)); % Calculate Pe
% **********#### Calculate BER for various EbNo values ###*************
% <insert code here..>
% Plot graph comparing theoretical BER with actual:
semilogy(y, Pe, '-r*');
legend('Theorerical (Pe)'); % Legend for graph
xlabel('Eb/No'); % Label for x-axis
ylabel('BER'); % Label for y-axis
% **********###--------------------------------####***********************
end
Hi,
I am simulating a QAM modulation for 2,4,16 & 64 QAM and want to produce the BER v EbNo graph for a noisy signal in order to compare to the theoretical value I have. i know this is relatively easy, but I'm not sure how to/the best way to do this. The basis of my code is below, so if someone could help with the relevant section (or be able to send me any QAM code you have..) i would greatly appreciate it, thanks... mjh
% Variables & parameters:
global M % Sets M as a global variable
global ynoise
bps=log2(M) % No. of bits per symbol
n = 30000; % No. of bits to process
Fd=1;Fs=1; % Sampling freq (input;output)
nsamp=1; % Oversampling rate
J= sqrt(-1); % To represent imag component J
% Generate signal with noise:
x = randint(n,1); % To create a random binary stream
xsym = bi2de(reshape(x,bps,length(x)/bps).','left-msb'); % Convert the bits in x into k-bit symbols.
y = dmodce(xsym,Fd,Fs, 'qask',M); % Modulate for M-QAM
ytx = y; % Transmitted signal
% Signal over AWGN channel
EbNo = 10; % NB: in dB
snr = EbNo + 10*log10(bps) - 10*log10(nsamp);
ynoise = awgn(ytx,snr,'measured');
%ynoise = awgn(y,(M-1)); % Transmit signal through an AWGN channel.
yrx = ynoise; % Received Signal
% BER:
figure; % To open new figure
% Theoretical BER curve, Pe...
xfunc = sqrt((3/(n^2-1)*EbNo)); % Set variable 'xfunc' = sqrt(2*) to use in Pe equation..
Pe = (2*(1-(1/n))*erfc(xfunc)); % Calculate Pe
% **********#### Calculate BER for various EbNo values ###*************
% <insert code here..>
% Plot graph comparing theoretical BER with actual:
semilogy(y, Pe, '-r*');
legend('Theorerical (Pe)'); % Legend for graph
xlabel('Eb/No'); % Label for x-axis
ylabel('BER'); % Label for y-axis
% **********###--------------------------------####***********************
end