我正在使用卷积码和 QAM-16 调制方案来模拟 CDMA 中 2 个用户之间的 BER。从我附上的图表来看,用户 1 和用户 2 的 BER 相同且恒定。SNR 似乎不影响传输。无论如何我可以改进图表吗?这是我的代码:
M = 16; % Modulation order
k = log2(M); % Bits per symbol
EbNoVec = (0:20)'; % Eb/No values (dB)
numSymPerFrame = 1; % Number of QAM symbols per frame
users=2; % Number of Users
trellis = poly2trellis(7,[171 133]);
tbl = 32;
rate = 1/2;
%------------------Generation of Walsh code--------------------------------
noOfSubCarrier =20; %Number of Data Sub-Carriers
walsh=hadamard(noOfSubCarrier);
code1=walsh(10,:);
code2=walsh(20,:);
berEst1 = zeros(size(EbNoVec));
berEst2 = zeros(size(EbNoVec));%Initialize the results vector
% The main processing loop executes the following steps:
% Generate binary data and convert to 64-ary symbols
% QAM modulate the data symbols
% Pass the modulated signal through an AWGN channel
% Demodulate the received signal
% Convert the demoduated symbols into binary data
% Calculate the number of bit errors
for n = 1:length(EbNoVec)
% Convert Eb/No to SNR
snrdB = EbNoVec(n) + 10*log10(k*rate);
% Reset the error and bit counters
numErrs1 = 0;
numErrs2 = 0;
numBits = 0;
% Generate binary data and convert to symbols
B=10;
dataIn1= rand(1,B);
dataIn2=rand(1,B);
symbols1= unique(dataIn1);
symbols2= unique(dataIn2);
probs1 = histc(dataIn1,symbols1)./numel(dataIn1);
probs2 = histc(dataIn2,symbols2)./numel(dataIn2);
[dict1, avglen1] = huffmandict(symbols1, probs1);
[dict2, avglen2] = huffmandict(symbols2, probs2);
comp1 = huffmanenco(dataIn1,dict1);
comp2 = huffmanenco(dataIn2,dict2);
% Convolutionally encode the data
dataEnc1 = convenc(comp1,trellis);
dataEnc2 = convenc(comp2,trellis);
% QAM modulate
txSig1 = qammod(dataEnc1,M,0);
txSig2 = qammod(dataEnc2,M,0);
%------------------Spreading & IFFT for User1------------------------------
Tx_data1=txSig1';
Spread_User1=Tx_data1*code1; % Spreading
Spread1=(Spread_User1)';
ifftdata_user1=ifft(Spread1); % Taking the IFFT
ifftdata1=ifftdata_user1';
%------------------Spreading & IFFT for User2------------------------------
Tx_data2=txSig2';
Spread_User2=Tx_data2*code2; % Spreading
Spread2=(Spread_User2)';
ifftdata_user2=ifft(Spread2); % Taking the IFFT
ifftdata2=ifftdata_user2';
%----------------------Addition of all signal------------------------------
TotSignal = Spread1+Spread2;
% Pass through AWGN channel
AwTotSignal = awgn(TotSignal,snrdB,'measured');
%-----------------------Removing the FFT & De-Spreading--------------------
fft_data_received =fft(AwTotSignal);
Rec_Data1=(AwTotSignal'*code1');
Rec_Data2=(AwTotSignal'*code2');
% Demodulate the noisy signal
rxSym1 = qamdemod(Rec_Data1,M,0);
rxSym2 = qamdemod(Rec_Data2,M,0);
data1=vitdec(rxSym1,trellis,5,'cont','unquant');
data2=vitdec(rxSym2,trellis,5,'cont','unquant');
% Convert received symbols to bits
%dataOut1 = de2bi(data1,k);
%dataOut2 = de2bi(data2,k);
% Calculate the number of bit errors
nErrors1 = biterr(comp1',data1);
nErrors2 = biterr(comp2',data2);
% Increment the error and bit counters
numErrs1 = numErrs1 + nErrors1;
numErrs2 = numErrs2 + nErrors2;
numBits= numBits + numSymPerFrame*k;
% Estimate the BER
berEst1(n) = numErrs1/numBits;
berEst2(n) = numErrs2/numBits;
end