error in matlab code for snr estimation

조회 수: 4 (최근 30일)
Shweta
Shweta 2014년 4월 22일
답변: Jan 2014년 4월 22일
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:

답변 (1개)

Jan
Jan 2014년 4월 22일
It is very unlikely that readers in the forum spend the time for reading your paper.

카테고리

Help CenterFile Exchange에서 Octave에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by