BER(bit error rate problem)
2 ビュー (過去 30 日間)
古いコメントを表示
I am writing code for BER(bit error rate ) of OOK(ON OFF keying signal),but there is little problem in my code.Problem is that my figure 4 is not close to my figure 1 in my code.My figure 4 shoulde be like this.Second thing is that at fs(sampling frequency)=360 and bode=10 my BER should be zero but now it is giving me some BER which is not right.Please remember this thing that my signal should be in between 0 and 1.I am pasting my code please help
clc,close all,clear all
codn=100;
EbN0=1:12;
q=1.6e-19; %
% signal-to-noise ratio in dB.
SNR=10.^(EbN0./10); % signal-to-noise ratio
Ib=202e-6; % Background Noise Current+interfernce
N0=2*q*Ib; % Noise Spectral Density, 2*q*Ib
fs=360;
bode=10;
code=rand(1,codn)
code_len=round(1/bode/(1/fs)) % no of samples/symbol
sgma=zeros(1,length(SNR));
ber=zeros(1,length(SNR));
for iii=1:length(SNR)
for ii=1:codn
x((ii-1)*code_len+1:code_len*ii)=code(ii);
end
cl=SNR(iii)
size(x)
sgma(iii)=sqrt(N0/2/0.1);
% y=x+sgma(iii)*randn(1,length(x)); % if want to add noise
x2 = x-(1/2); % get rid of most of the dc peak
pt=ones(1,code_len);
rt=pt;
% set up time and frequency arrays
length(x)
u = length(x2);
N = 2^ceil(log2(abs(u)));
delt = 1/fs;
delf1=fs/u;
figure(1)
tvec2=(1:length(x2))*delt;
plot(tvec2,round((x2(1,:)+0.5)))
title('orignal baseband')
xlabel('time');
ylabel('amplitude')
ylim([-1 1.5]);
y = fftshift(fft(x2)/N);
z=abs(y);
figure(2)
fvec2=(-length(x2)/2:length(x2)/2-1)*delf1;
plot(fvec2,z)
title('FFT')
xlabel('frequency')
ylabel('amplitude')
figure(3)
z=y;
z(abs(fvec2)>50 & abs(fvec2)<=150)=0;
plot(fvec2,abs(z))
xlabel('frequency removed from 50 to 150 HZ');
ylabel('amplitude')
figure(4)
zf=fftshift(z)*N;
zifft=ifft(zf)+0.5;
MF_out=conv(zifft,rt)*0.5; % sampling time = 0.1
MF_out_downsamp=MF_out(code_len:code_len:end);
MF_out_downsamp=MF_out_downsamp(1:100);
Rx_th=zeros(1,codn);
%Rx_th(find(MF_out_downsamp>1/2))=1;
%Rx_th(find(MF_out_downsamp>mean(abs(MF_out_downsamp))))
for k=1:length(MF_out_downsamp)
if MF_out_downsamp(k)>mean(abs(MF_out_downsamp))
Rx_th(k)=1;
end
if code(k)>mean(abs(code))
code(k)=1;
end
end
nra=code==Rx_th
nerr=length(nra)-sum(nra)
ber(iii)=1/10^(nerr/length(nra)*cl)
end
plot(tvec2,(abs(zifft)))
ylim([-1 1.5])
title('recovered signal')
xlabel('time');
ylabel('amplitude')
figure;
semilogy(EbN0,ber,'b');
xlabel('Eb/N0,db');
ylabel('Bit Error Rate');
grid on
title('Bit error probability curve for OOK ');
legend('simulation','theory');
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!