内容发布更新时间 : 2024/12/22 12:15:57星期一 下面是文章的全部内容请认真阅读。
Ts = N * Tc; p = Eb / Ts;
%generate BPSK symbols randomly with value +1 or -1 x = bingen(x_num); x_original = x; x = sqrt(p)*x;
%generate Rayleigh fading
[env1,env2] = fade_diversity(length(x),;
%generate faded sequence x_fad1 = env1.*x'; x_fad1 = x_fad1';
x_fad2 = env2.*x'; x_fad2 = x_fad2';
%DS-SS modulate symbols with user code c = bingen(N);
y_fad1 = ds_mod(c(:),x_fad1); y_fad2 = ds_mod(c(:),x_fad2);
%scale by appropriate power factor %y = sqrt(p)*y;
-d AWGN to signal y_fad1 = awgn(y_fad1,1); y_fad2 = awgn(y_fad2,1);
%DS-SS demodulate symbols with user code x_de1 = ds_demod(c(:),y_fad1); x_de2 = ds_demod(c(:),y_fad2);
%choose branch with larger BENR ind1 = find(abs(x_de1) >= abs(x_de2)); ind2 = find(abs(x_de1) < abs(x_de2));
x_de(ind1) = x_de1(ind1); x_de(ind2) = x_de2(ind2);
Tcision
x_de(find(x_de < 0)) = -1; x_de(find(x_de >=0)) = 1;
Pe = length(find(x_original - x_de))/x_num; Plot_Pe = [Plot_Pe Pe]; end %end for EbNo
%display the calculated Pd and Pfa
Plot_Pe
%plot Pe versus Eb/No %subplot(2,1,1)
semilogy(plot_EbNo,Plot_Pe,'ro-') xlabel('Eb/No (dB)') ylabel('BER')
s=sprintf('BER versus Eb/No in Rayleigh fading and AWGN'); title(s); grid on;
%********************************************************************* % This program computes the average BER in Rayleigh fading %
and AWGN
%
% AUTHOR: Wenbin Luo % DATE : 04/28/01 % % %
%******************************************************************** clear all; %close all;
format long;
%set up the threshold Vt Vt = 0;
Plot_Pe = []; N = 16; x_num = 10000;
plot_EbNo = -20:2:30; %-20:2:10; for EbNo = -20:2:30,
%convert back from dB Eb_No = EbNo; ? Eb_No = 10.^(Eb_No/10); %assume No = 2; No = 2;
Eb = No * Eb_No; êlculate power p Tc = 1; Ts = N * Tc; p = Eb / Ts;
%generate BPSK symbols randomly with value +1 or -1 x = bingen(x_num); x_original = x; x = sqrt(p)*x;
%generate frequency selective Rayleigh fading tmp = fade_fs(x,7); x = tmp';
%DS-SS modulate symbols with user code c = bingen(N); y = ds_mod(c(:),x);
%scale by appropriate power factor %y = sqrt(p)*y;
-d AWGN to signal y = awgn(y,1);
%DS-SS demodulate symbols with user code x_de = ds_demod(c(:),y);
Tcision
x_de(find(x_de < 0)) = -1; x_de(find(x_de >=0)) = 1;
Pe = length(find(x_original - x_de))/x_num; Plot_Pe = [Plot_Pe Pe]; end %end for EbNo