It seems like there might be a couple of issues in your code.
1. BitInput/BitsPerSymbol Mismatch:
You have set 'BitInput' to true in the modulator, which means it expects input in bits. However, in the channel, you specified 'BitsPerSymbol' as 2. Ensure consistency in bit handling between the modulator and the channel.
2. AWGN Channel Initialization:
It's better to initialize the AWGN channel outside the loop to keep the noise consistent for each Eb/N0 value.
3. Data Size Mismatch:
Make sure the length of `txData` matches the number of bits required for the modulation scheme. For OQPSK, the number of bits per symbol is typically 2.
Here's an adjusted version:
close all
clear
clc
PulseShape = 'Normal raised cosine';
RolloffFactor = 0.25;
FilterSpanInSymbols = 4;
oqpskmod = comm.OQPSKModulator('BitInput', true, 'PulseShape', PulseShape, 'RolloffFactor', RolloffFactor, 'FilterSpanInSymbols', FilterSpanInSymbols);
oqpskdemod = comm.OQPSKDemodulator('BitOutput', true, 'PulseShape', PulseShape, 'RolloffFactor', RolloffFactor, 'FilterSpanInSymbols', FilterSpanInSymbols);
EbNo = [0 0:20]';
errorTot = zeros(length(EbNo), 1);
% Initialize AWGN channel outside the loop
channel = comm.AWGNChannel('BitsPerSymbol', 2);
%Temporarily Commenting out CVS Read
%txData = csvread("PRN15_Binary.csv")';
%txData = txData(1:end-1);
txData = [1,1,1,1,0,0,1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,0,0,0,1]';
for i = 1:length(EbNo)
% Set EbNo for each iteration
channel.EbNo = EbNo(i);
modSig = oqpskmod(txData);
rxSig = channel(modSig);
rxData = oqpskdemod(rxSig);
% Count errors
error = sum(txData ~= rxData);
errorTot(i) = errorTot(i) + error;
end
errorTot
(This code ran without error in Matlab 2023B.)
This code possibly addresses the mentioned issues... Let me know if this answered your question, resulted in follow up questions, or if your quesiton was totally misunderstood.