?? comparisons of bit error probabilities with adaptive mmse.m
字號:
m = 3; % number of LSRs
N = 2^m-1; %processing gain %processing gain
maxusers = floor(2*N); % max number of users
noisevar = 1;
SNR_dB = 12; % SNR in dB
SNR = 10^(SNR_dB/10);
totalbits = 10000;
overhead = .05; %ratio of training bits to total transmitted number of bits.
trainbits = totalbits*overhead; % Choosing number of training bits
for K=1:maxusers
A = eye(maxusers)*sqrt(10^(SNR_dB/10)); % Amplitude of each User
M = zeros(N,K); % initilizing the weight matrix
S =signature_matrix(m,K); %generate signature matrix.
for num_bits=1:totalbits
b(:,num_bits) = sign(normrnd(zeros(K,1),1)); %generate random bit values for each user
b_frame = b(:,num_bits); %bits of users in num_bits'th frame duration
n = normrnd(0,sqrt(noisevar),N,1); %Assume zero mean AWGN
y_noisefree = S*A*b_frame; %generate received vector (after demodulation)
y = y_noisefree+n; %add noise to received signal
if num_bits<=trainbits %training mode for adaptive MMSE
[b_AMMSE(:,num_bits), M, mse(num_bits)] =
MUD_AMMSE(y,M,b_frame,num_bits);
else %detection mode for adaptive MMSE
[b_AMMSE(:,num_bits), M, temp] = MUD_AMMSE(y,M);
mse(num_bits) = (temp-b_frame)'*(temp-b_frame); %calculate actual squared
%error
end
b_MMSE(:,num_bits) = MUD_MMSE(y,S,A,noisevar); %Multiuser Minimum
%Mean Square Error Detection
b_MF(:,num_bits) = MUD_MF(y,S); %Single User Matched Filter Detection
b_Dec(:,num_bits) = MUD_Dec(y,S); %Multiuser Decorrelator
end
%Find all the errors made
e_MF = b-b_MF;
e_Dec = b-b_Dec;
e_MMSE = b-b_MMSE;
e_AMMSE = b(:,trainbits+1:totalbits)-b_AMMSE(:,trainbits+1:totalbits);
%Determine BER's
Pe_MF(K) = length(find(e_MF))/(K*totalbits);
Pe_Dec(K) = length(find(e_Dec))/(K*totalbits);
Pe_MMSE(K) = length(find(e_MMSE))/(K*totalbits);
Pe_AMMSE(K) = length(find(e_AMMSE))/(K*(totalbits-trainbits));
clear b b_frame n y_noisefree b_MMSE b_MF b_Dec b_AMMSE
K %print out where the iteration is for control purposes
end
%Plot the BER
K=1:maxusers;
semilogy(K,Pe_MF,K,Pe_Dec,K,Pe_MMSE,K,Pe_AMMSE)
legend('MF','Dec','MMSE','AMMSE');
title('Probability of Error');
xlabel(['Number of users, K for N = ',num2str(N)]);
ylabel('BER');
beep %signal end of simulation
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -