cdma的MATLAB仿真源程序

2019-04-21 14:12

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

% This function pertains to the addition of AWGN with mean zero and % parameter 'variance' to an input signal. %

% AUTHOR: Wenbin Luo % DATE : 04/12/01 % % SYNOPSIS: y = awgn(x,var) % x ---> input signal % var ---> variance

% y ---> y = x + AWGN

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

function y = awgn(x,var) w = randn(1,length(x)); w = w - mean(w)*ones(size(w)); w = sqrt(var)*(w / std(w)); x = x(:); w = w(:); y = x + w;

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

% This function does the DS-SS modulation %

% AUTHOR: Wenbin Luo % DATE : 04/28/01 % % SYNOPSIS: y = ds_mod(c,x) % c ---> user code (column vector) % x ---> input signal (row vector)

% y ---> tmp = c*x, y = tmp(:) (ds-ss modulated signal, column vector)

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

function y = ds_mod(c,x) tmp = c*x; y = tmp(:);

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

% This function generates random +1/-1 sequence with independent identically % distributed symbols %

% AUTHOR: Wenbin Luo

% DATE : 04/28/01 % % SYNOPSIS: x = bingen(L)

% L ---> number of random symbols

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

function x = bingen(L)

%generate L symbols randomly with value +1 or -1 x = rand(1,L);

x(find(x<0.5)) = -1; x(find(x >=0.5)) = 1;

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

% This function does the DS-SS modulation %

% AUTHOR: Wenbin Luo % DATE : 04/28/01 % % SYNOPSIS: x = ds_demod(c,y) % c ---> user code (column vector)

% y ---> tmp = c*x, y = tmp(:) (ds-ss modulated signal, column vector) % x ---> input signal (row vector)

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

function x = ds_demod(c,y)

tmp = reshape(y, length(c), length(y)/length(c)); tmp = tmp';

%x is a column vector x = tmp * c;

% convert to row vector x = x';

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

% This function does the DS-SS modulation %

% AUTHOR: Wenbin Luo % DATE : 04/28/01 % % SYNOPSIS: y = ds_mod(c,x) % c ---> user code (column vector) % x ---> input signal (row vector)

% y ---> tmp = c*x, y = tmp(:) (ds-ss modulated signal, column vector)

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

function y = ds_mod(c,x) tmp = c*x; y = tmp(:);

%*********************************************************** % This mfunction generates faded envelope and phase % corresponding to Rayleigh fading %

% AUTHOR: Wenbin Luo % DATE : 04/27/01 %

% FUNCTION SYNOPSIS: % [env,phi] = fade(L,para) %

% Parameter Description:

% L : number of samples needed % variance : variance

%********************************************************** function [env,phi] = fade(L,variance) % Error check if variance <= 0

error('Positive variance needed') elseif nargin ~= 2

error('Insufficient input parameters') end

% Generate bivariate Gaussian uncorrelated % random variables mu = zeros(1,2);

C = variance*eye(2,2); r = mvnrnd(mu,C,L);

% Convert to polar coordinates and compute % magnitude and phase z = r(:,1) + j*r(:,2);

env = abs(z); phi = angle(z);

%********************************************************** %*********************************************************** % This mfunction generates two channels of faded % envelope and phase corresponding to % Rayleigh fading %

% AUTHOR: Wenbin Luo % DATE : 04/27/01

%

% FUNCTION SYNOPSIS:

% [env,phi] = fade_diversity(L,para) %

% Parameter Description:

% L : number of samples needed % variance : variance

%********************************************************** function [env1,env2] = fade_diversity(L,variance) % Error check if variance <= 0

error('Positive variance needed') elseif nargin ~= 2

error('Insufficient input parameters') end

% Generate bivariate Gaussian uncorrelated % random variables mu = zeros(1,4);

C = variance*eye(4,4); r = mvnrnd(mu,C,L);

% Convert to polar coordinates and compute % magnitude and phase z1 = r(:,1) + j*r(:,2); z2 = r(:,3) + j*r(:,4); env1 = abs(z1); env2 = abs(z2);

%********************************************************** %*********************************************************** % This mfunction generates frequency selective % Rayleigh fading %

% AUTHOR: Wenbin Luo % DATE : 05/02/01 %

% FUNCTION SYNOPSIS: % y = fade_fs(x,L) %

% Parameter Description: % y : output signal % x : input signal % L : number of independent Rayleigh % fading process

%********************************************************** function y = fade_fs(x,L)

% Generate bivariate Gaussian uncorrelated % random variables tmp1 = 0:1:(L-1); tmp1 = exp(-tmp1); tmp(1:2:2*L-1) = tmp1; tmp(2:2:2*L) = tmp1;

mu = zeros(1,2*L); C = 0.5*diag(tmp); x_len = length(x);

r = mvnrnd(mu,C,x_len);

% Convert to polar coordinates and compute magnitude x = x(:);

y = zeros(x_len,1); for i = 1:L,

z = r(:,2*i-1) + j*r(:,2*i);

env = abs(z); %phi = angle(z); tmp_y = env.*x;

tmp_y = [zeros(i-1,1); tmp_y(1:x_len-i+1)]; y = y + tmp_y; end

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

%********************************************************************** % This program computes the average BER of a DS-SS/BPSK % communication system with binary BCH code in the AWGN channel %

% AUTHOR: Wenbin Luo % DATE : 04/28/01 % % final11_extra.m %

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

%function Plot_Pe = final11_extra()

clear all; %close all;

format long;

%set up the threshold Vt Vt = 0;

Plot_Pe = [];


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

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

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

马上注册会员

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