error in matlab code for snr estimation
4 views (last 30 days)
Show older comments
Hello all,
I have written following matlab code for snr estimation using the method described in the attached paper. My estimated snr values are not matching with the true snr values. Kindly help.
clc
clear all;
close all;
% Generate data.
M = 16; % Alphabet size
Pd = 10000; % Length of data
k = log2(M); % Number of bits per symbol
ini_phase=0; % Initial phase
xin = randi([0 1],Pd,1); % Random binary data stream
xin = reshape(xin, length(xin)/4, 4); % Reshape data into binary 4-tuples
xsym = bi2de(xin); % Convert to integers
qamsig = qammod(xsym,M,ini_phase,'gray'); % QAM signal
snr_theory = 0:2:4; % Theoretical value of SNR
P1=1/4;
P2=3/4;
R(1)=1;
R(2)=3.15;
c2 = 1;
c4 = R(1).^4.*P1+R(2).^4.*P2;
c6 = R(1).^6.*P1+R(2).^6.*P2;
N=2; % Noise variance of 2dB
n = sqrt(N)*[randn(2500,1) + j*randn(2500,1)]; % white gaussian noise
for a=1:length(snr_theory)
rxsig = qamsig + 10^(-snr_theory(a)/20)*n; % noise addition
y=abs(rxsig);
sum_y = 0;
sum_y2 = 0;
sum_y4 = 0;
sum_y6 = 0;
for i=1:length(y)
sum_y=sum_y+y(i);
sum_y2=sum_y2+y(i)^2;
sum_y4=sum_y4+y(i)^4;
sum_y6=sum_y6+y(i)^6;
end
M2=sum_y2/length(y);
M4=sum_y4/length(y);
M6=sum_y6/length(y);
m=((M2.*M4)/M6);
v=[((m.*c6)-c4) ((9.*m.*c4)-c4-4) ((18.*m)-6) ((6.*m)-2)];
r=roots(v);
snr_est_M2M4M6 = r(1); % estimation value
end
figure(2);
%plot estimation value
plot(snr_theory,snr_theory);
hold on
plot(snr_theory,snr_est_M2M4M6,'-o');
hold off
The graph of estimated snr vs true snr is shown as follows:

0 Comments
Answers (1)
Jan
on 22 Apr 2014
Please read: http://matlab.wikia.com/wiki/FAQ#Can_you_program_up_the_algorithm_in_this_article_for_me_and_explain_it_to_me.3F
It is very unlikely that readers in the forum spend the time for reading your paper.
0 Comments
See Also
Categories
Find more on Octave in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!