内容发布更新时间 : 2024/12/22 12:22:29星期一 下面是文章的全部内容请认真阅读。
% 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 = *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 % % %
%**********************************************************************
%function Plot_Pe = final11_extra() clear all; %close all;
format long;
%set up the threshold Vt Vt = 0;
Plot_Pe = []; N = 16; x_num = 2500; plot_EbNo = -20:2:10; for EbNo = -20:2: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); x_org = x;
-ds error-correcting code
enc_N = 15; enc_K = 5; %7/4 or 15/5 x(find(x < 0)) = 0;
x = encode(x,enc_N,enc_K,'bch'); x = x';
x(find(x == 0)) = -1;
%DS-SS modulate symbols with user code c = bingen(N); y = ds_mod(c(:),x);
%scale by appropriate power factor