error with 8psk modulation
2 views (last 30 days)
Show older comments
Hi, I'am trying to test a code of the 8PSK modulation,this is the code:
custMap = [0 2 4 6 7 5 3 1];
hMod = comm.PSKModulator(8,'BitInput',true,'SymbolMapping','Custom','CustomSymbolMapping',custMap);
hDemod = comm.PSKDemodulator(8,'BitOutput',true,'SymbolMapping','Custom','CustomSymbolMapping',custMap);
% Display the modulator constellation.
constellation(hMod)
hChan = comm.AWGNChannel('BitsPerSymbol',log2(8));
hErr = comm.ErrorRate;
% Initialize the simulation vectors. The Eb/No is varied from 0 to 10 dB in
% 1 dB steps.
ebnoVec = 0:10;
ber = zeros(size(ebnoVec));
for k = 1:length(ebnoVec)
% Reset the error counter for each Eb/No value
reset(hErr)
% Reset the array used to collect the error statistics
errVec = [0 0 0];
% Set the channel Eb/No
hChan.EbNo = ebnoVec(k);
while errVec(2) < 200 && errVec(3) < 1e7
% Generate a 1000-symbol frame
data = randi([0 1],4000,1);
% Modulate the binary data
modData = step(hMod,data);
% Pass the modulated data through the AWGN channel
rxSig = step(hChan,modData);
% Demodulate the received signal
rxData = step(hDemod,rxSig);
% Collect the error statistics
errVec = step(hErr,data,rxData);
end
% Save the BER data
ber(k) = errVec(1);
end
berTheory = berawgn(ebnoVec,'psk',8,'nondiff');
figure
semilogy(ebnoVec,[ber; berTheory])
xlabel('Eb/No (dB)')
ylabel('BER')
grid
legend('Simulation','Theory','location','ne')
but I have a problem at this line
modData = step(hMod,data);
this is the error:
how can I solve the problem pleaze and thanks
0 Comments
Answers (1)
Rick Rosson
on 30 Dec 2014
Instead of
data = randi([0 1],4000,1);
please try
data = randi([0 1],3000,1);
0 Comments
See Also
Categories
Find more on PSK in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!