[英]How to generate BER performance for different dB?
I want to create a graph that generates BER
vs Eb/N0
for different signal-to-noise ratios.我想创建一个图表,为不同的信噪比生成
BER
与Eb/N0
的关系。 Try to create a for loop but it is not working, can you help me with that?尝试创建一个 for 循环,但它不起作用,你能帮我吗? I am quite new to this Matlab and don't know where things are getting wrong.
我对这个 Matlab 很陌生,不知道哪里出了问题。
figure(1)
for j = 1:length(SIR)
for i = 1:10
BER = [];
BER_az = [];
Pj = 2*Lc / (10^(SIR(j)/10));
jammer = sqrt(Pj/2)*jam_mod.*exp(1i*2*pi*0.12*(1:Ldata*Lc)).';
[P,x] = pwelch(jammer+x_in,[],[],[4096], Lc,'twoside');
%clear jam_mod;
EB2N(i) = (i-1);
EB2N_num = 10^(EB2N(i)/10);
Var_n = Lc/(2*EB2N_num); %variance
signois = sqrt(Var_n); %standard deviation
awgnois = signois*noise;
y_out = x_in+awgnois+jammer;
Y_out = reshape(y_out,Lc,Ldata).';
clear y_out awgnois;
z_out = Y_out*Pcode;
%decision based on the sign of the samPles
dec1 = sign(real(z_out))+j*sign(imag(z_out));
%comPare against the original data to calcuate BER
BER = [BER;sum([real(data_sym)~=real(dec1);...
imag(data_sym)~=imag(dec1)])/(2*Ldata)];
BER_az = [BER_az;0.5*erfc(sqrt(EB2N_num))];
end
if (j == 1)
figber = semilogy(EB2N,BER_az, 'k-');
hold on;
end
figber = semilogy(EB2N,BER);
clear BER;
clear BER_az;
legend('No jamming','SNR:-5 dB', 'SNR:-8 dB', 'SNR:-10 dB', 'SNR:-20 dB');
set(figber,'Linewidth',2);
xfont = xlabel('E_b/N in dB');
yfont = ylabel('bit error rate');
title('DSSS with sPreading gain 11');
end
You must first initialize your SIR
variable just before the start of the loop.您必须在循环开始之前首先初始化您的
SIR
变量。 Also specify the SIR
value before the for loop.还要在 for 循环之前指定
SIR
值。
SIR = [0:1:10]; % For example for a SIR from 0 to 10 in steps of 1.
In the program, specify the following values: Lc
, Jam_mod
, Ldata
, X_in
, noise
and data_sym
.在程序中,指定以下值:
Lc
、 Jam_mod
、 Ldata
、 X_in
、 noise
和data_sym
。
This post will give you other openings as well.这篇文章也会给你其他的机会。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.