#### sundar123

##### Newbie level 6

**value in e(i)**

hi

can any body help me to clear me that why i am not getting different values in e(i)

because of which the BER curve is not showing properly

thanks .....code is given below

clear all;

N=10^4 %symbols

M=16; % for 16 qam

error=0;

count=1;

SNR1=[0:20];

a=SNR1/10;

SNR=10.^a;

% EbN0=20;

L=log2(M);% number of bits

bits=1000;

for i=1:length(SNR)

EbN0=SNR(i);

data=((sign(randn(N*L,1)+1))>0.5).'; % bit to send

tbl=[0;1];

for i=1L-1) tbl=[tbl zeros(length(tbl),1); flipud(tbl) ones(length(tbl),1)]; end;

tmp = sortrows([bi2de(tbl)'; [0 : M-1]]');

Reordering = tmp,2)';

Vals = [0:M-1];

Y= fix(Vals./sqrt(M)); % y=0:3 => row

% % counting forward for odd rows, backward for even rows

x = -sign(mod(Y,2)-0.5).*(bitand(Vals,sqrt(M)-1)*2+1-sqrt(M)); % x = +/- (0:3)*2+1-4

y = sqrt(M)-Y*2-1; % y = 4 - y*2-1

constellation = x + j*y; % constellation points % construct result

% scatterplot(constellation);

constellationpower = sqrt(mean(abs(constellation).^2)); % calculate average power

modulationconstellation= constellation(Reordering+1)/constellationpower;

EsN0 = EbN0 * L;

% needed to perform bi2de conversion

bpwr = (2.^(0L-1)));

% scale looked up modulated constellation index obtained by bi2de conversion

if ((mod(size(data,2),L)~=0) & (1))

data = [data zeros(1,L-mod(size(data,2),L))];

end;

z = sqrt(EsN0) * modulationconstellation( bpwr*reshape(data,L,size(data,2)/L) + 1 );

% noise

noise=1/sqrt(2)*(randn(1,length(z))+j*randn(1,length(z)));

h=1;

y=h*z+noise;%modulation

% demodulation

% getting index of a minimum value

for k=1:length

sig=y(k)*ones(M,1);

[m,index(k)]=min(sig-(h*sqrt(EsN0)*modulationconstellation.'));

end

% need to perform decimal to binary conversion

binary=(de2bi(index-1)).';

bitrcv=binary(; % bit recieved

data=data(;

% error=error+e;

%actually facing problem in this part

e(i) =length(find([data- bitrcv])); % finding errors...

end

BER=e/b;

close all;

figure

semilogy(SNR,BER,'mx-','LineWidth',2);

xlabel('SNR');

ylabel('Bit Error Rate');

title('Bit error probability curve for 16-QAM modulation');