Why do i need to divided by log2(M) * Ts instead of Ts ? For the symbol error rate of 8-PSK
4 views (last 30 days)
Show older comments
I saw this code of 8-PSK in the internet,and i don't know why do i need to divided by log2(M) * Ts instead of Ts
code:
M=8;
r=sqrt(3);
Ts=10^4;
SNR_dB=[-3,0,3,6,9];
Ne=zeros(1,length(SNR_dB));
y=zeros(1,5);
theta=zeros(1,M);
Eav=r^2;
Eavb=Eav/log2(M);
for ii=1:length(SNR_dB)
SNR=10^(SNR_dB(ii)/10);
No=Eavb/SNR;
for jj=1:M
theta(jj)=((jj-1)*2*pi/M);
end
for t=1:Ts
s=randi(M)-1;
s_bin=dec2bin(s,3)-'0';
s_new=r*cos(theta(s+1))+1i*r*sin(theta(s+1));
n=randn(1,2)*sqrt(No/2);
r0=real(s_new)+n(1);%
r1=imag(s_new)+n(2);
theta_r=angle(r0+r1*1i);
if -1*pi<theta_r && theta_r <0
theta_r=theta_r+2*pi;
end
if (theta(1)-(pi/M)+(2*pi))<theta_r ||theta_r <(theta(1)+(pi/M))
s_hat=0;
s_hat_bin=dec2bin(s_hat,3)-'0';
end
detect
for k=2:M
if (theta(k)-(pi/M))<theta_r && theta_r<(theta(k)+(pi/M))
s_hat=k-1;
s_hat_bin=dec2bin(s_hat,3)-'0';
end
end
for n=1:log2(M)
if s_bin(n)~=s_hat_bin(n)
Ne(1,ii)=Ne(1,ii)+1;
end
end
y(1,ii)=Ne(1,ii)./(log2(M)*Ts)%why do i need to divided by log2(M) * Ts instead of Ts
end
end
semilogy(SNR_dB,y,'-r');
grid on
Because the error probability is : total error numuber/total number,in this code,i create Ts number,and turn them into the the 3bits binary code,i mean 0=>000,7=>111.So in fact,i create Ts numbers instead of log2(M)*Ts.
And i modify these code
for n=1:log2(M)
if s_bin(n)~=s_hat_bin(n)
Ne(1,ii)=Ne(1,ii)+1;
end
end
y(1,ii)=Ne(1,ii)./(log2(M)*Ts)
to
if s_bin~=s_hat_bin
Ne(1,ii)=Ne(1,ii)+1
end
y(1,ii)=Ne(1,ii)./Ts
The simulation become wrong ,why?
The second code i can explain that i compare the nth bit of s_bin with nth bit of s_hat_bin,if their bit are not equal,then the error number will plus one.
The third code i can explain that i compare the s_bin with nth bit of s_hat_bin,i mean like s_bin=000,s_hat_bin = 001,then s_bin is not equal to s_hat_bin so plus 1.
Or is the second code for bit error rate and the third code for the symbol error rate?
Can anyone tell me?
0 Comments
Answers (1)
KALYAN ACHARJYA
on 29 Apr 2019
Edited: KALYAN ACHARJYA
on 29 Apr 2019
Why do i need to divided by log2(M) * Ts instead of Ts ?
Please check the below expression and discuss with your communication teacher.
Detail here
See Also
Categories
Find more on Test and Measurement 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!