Lets say, I have 10 randomly generated bits (0's and 1's) in matlab. From my other parameter calculations, I have about 5 samples, this means 1 bit/5 samples (each bit is replicated 5 times). My total data vector will be 1 x 50 length. After this i perform BPSK modulation and multiply the data (baseband) with a carrier wave to form a data signal (passband). After this I add AWGN and then again multiply the signal with the carrier (from passband, back to baseband).
After the above process is completed i have to make the decision to get back the 0's and 1's to compare it with the initially generated bits. How should i proceed with it?
Does the below code makes sense or am I missing something?
data = randi(1,[1,0],10);
...
...
...
(steps as explained above)
%----bits retrieval------
variable = [];
for i = 1:length(data)
sum = 0;
for j = (i*5-4):length(final)
sum = sum + final(j);
c = mod(j,5);
if c == 0
break
end
end
if sum > A
variable = [variable 1];
else
variable = [variable 0];
end
end
%--------------------------code ends-----------------------------
here,
A is the amplitude of the carrier wave
final is the vector onto which i have perform the decision to check if its a bit 1 or bit 0.