cdma的MATLAB仿真源程序(5)

2019-04-21 14:12

Plot_Pe

%plot Pe versus Eb/No %subplot(2,1,1)

semilogy(plot_EbNo,Plot_Pe,'r*-') 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 versus Eb/No of K users % transmitting BPSK symbols at an equal power level using a % DS-CDMA scheme assumming perfect synchronism and orthogonal % codes in AWGN %

% AUTHOR: Wenbin Luo % DATE : 04/29/01 % % final31.m %

%********************************************************************

clear all; %close all;

format long;

%set up the threshold Vt Vt = 0;

Plot_Pe = [];

K = 16; N = 32;

x_num = 5000;

plot_EbNo = -20:3:10; for EbNo = -20:3:10,

%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);

%DS-SS modulate symbols with user code UserCode = hadamard(N); c = UserCode(1,:); y = ds_mod(c(:),x);

-d other users' signal as interference for t = 2:1:K,

tmp_x = bingen(x_num); tmp = UserCode(t,:);

tmp_y = ds_mod(tmp(:),tmp_x); y = y + tmp_y; end % t

%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 - 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,'m*-')

xlabel('Eb/No (dB)') ylabel('BER')

title('BER versus Eb/No using DS-CDMA: perfect synchronism between users'); grid on;

%********************************************************************** % This program computes the average BER versus Eb/No of K users % transmitting BPSK symbols at an equal power level using a % slow FH-MA scheme assumming perfect synchronism and orthogonal % codes in AWGN %

% AUTHOR: Wenbin Luo % DATE : 05/01/01 % % final31_fh.m %

%*********************************************************************

clear all; %close all;

format long;

%set up the threshold Vt Vt = 0;

Plot_Pe = [];

K = 16; %4,8,16 N = 32;

x_num = 5000;

plot_EbNo = -20:3:10; for EbNo = -20:3:10,

%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);

%DS-SS modulate symbols with user code UserCode = fh(N,K); c = UserCode(1,:); y = ds_mod(c(:),x);

-d other users' signal as interference for t = 2:1:K,

tmp_x = bingen(x_num); tmp = UserCode(t,:);

tmp_y = ds_mod(tmp(:),tmp_x); y = y + tmp_y; end % t

%scale by appropriate power factor y = sqrt(p)*y;

-d AWGN to signal y = awgn_complex(y,1);

%DS-SS demodulate symbols with user code x_de = real(ds_demod(conj(c(:)),y));

Tcision

x_de(find(x_de < 0)) = -1; x_de(find(x_de >=0)) = 1;

Pe = length(find(x - 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,'m*-') xlabel('Eb/No (dB)') ylabel('BER')

title('BER versus Eb/No using slow FH-MA: perfect synchronism between users'); grid on;

%********************************************************************* % This program computes the average BER versus Eb/No of K users

% transmitting BPSK symbols at an equal power level using a % DS-CDMA scheme assumming a random asynchronism between users %

% AUTHOR: Wenbin Luo % DATE : 04/29/01 % % final32.m %

%********************************************************************

clear all; %close all;

format long;

%set up the threshold Vt Vt = 0;

Plot_Pe = [];

K = 4; N = 32;

x_num = 30000;

%generates a random asynchronism between users asyn = rand(1,K)*6; %asyn = floor(asyn); asyn = floor(asyn) + 1;

plot_EbNo = -20:3:50; for EbNo = -20:3:50,

%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);


cdma的MATLAB仿真源程序(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:非谓语动词用法详解

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: