Hi Dragos-Valentine,
I investigated the code shared by you and made the following observations and incorporated answers to your queries into the same observations.
- if the data rate is correct and how exactly do I define the data rate with these parameters?
I did not get what you meant by defining the data rate. I understand that you are comparing the theoretical BER with the simulation results. To calculate BER, why do you need to define the data rate? Note that the BER is the ratio of the number of bits received erroneously to the number of bits transmitted.
2. is it correct to use the rectpulse AND raised cosine filters at the same time?
It is worth noting that both raised cosine filters and rectangular filters are pulse shaping filters. You should use either of these at the transmitter and receiver to reverse the operation at the transmitter. You do not need to use both filters at the same time.
3. how do I account for the delay of the raised cosine filters? That might be why the result is not as the theory? Are the filters matched?
The raised cosine filter creates a total symbol delay of txfilter.FilterSpanInSymbols/2 + rxfilter.FilterDelayInSymbols/2. To convert this symbol delay into a bit delay, multiply the symbol delay by the number of bits per symbol. You need to consider this delay while calculating BER.
The modified code is as follows:
x = randi([0 1], NSymbols*bitPerSymbol, 1);
y = qammod(x, M, "InputType","bit","UnitAveragePower",true);
txfilter = comm.RaisedCosineTransmitFilter;
rxfilter = comm.RaisedCosineReceiveFilter;
calculated_ber = zeros(1, length(EbN0));
for idx = 1 : length(EbN0)
snr = EbN0(idx) + 10*log10(bitPerSymbol) - 10*log10(txfilter.OutputSamplesPerSymbol);
chanOut = awgn(txOut, snr,"measured");
rxOut = rxfilter(chanOut);
received_w = qamdemod (rxOut,M, "OutputType","bit","UnitAveragePower", true);
delayInSymbols = txfilter.FilterSpanInSymbols/2 + rxfilter.FilterSpanInSymbols/2;
delayInBits = delayInSymbols * bitPerSymbol;
received_wAlligned = received_w(1+delayInBits:end);
xAlligned = x(1:end-delayInBits);
calculated_ber(idx) = nnz(xAlligned ~= received_wAlligned)/ length(xAlligned);
berTheory = berawgn(EbN0,'qam',16);
semilogy(EbN0, calculated_ber,'o', "MarkerSize",10);
semilogy(EbN0, berTheory, "LineWidth",2);
legend('Simulated BER','Theory BER')
Note that for high values of SNR, it is not possible to calculate the BER through simulation with current code due to constraints on the system on which you are running the simulation. For a high SNR, you need to consider a high value for the number of symbols transmitted to capture the erroneous bits in transmission. In the following figure, you can see the simulated BER until "EbN0 = 14" matching the theoretical BER. For higher values, simulated BER is zero and is not plotted on the logarithmic Y-axis.