I have another problem. Can someone check and tell me what should I do?

1 vue (au cours des 30 derniers jours)
Alexandra Diaconu
Alexandra Diaconu le 30 Août 2018
Commenté : Dennis le 30 Août 2018
This is the error message: >> p4_16_Simulate_BER_of_BPSK_Mod_in_the_AWGN_Channel Index exceeds matrix dimensions.
Error in p4_16_Simulate_BER_of_BPSK_Mod_in_the_AWGN_Channel (line 31) bin_signal=bin_signal(1:SigLen*nsamp);
This is the code:
Rb=1;
% normalized bit rate
fc=Rb*5;
% carrier frequency;
Tb=1/Rb;
% bit duration
Eb=1;
% energy per bit
SigLen=1000;
% number of bits or symbols
fsamp=fc*10;
% sampling rate
nsamp=fsamp/Rb;
% samples per symbols
Tsamp=Tb/nsamp;
% sampling time
Tx_filter=ones(1,nsamp);
% transmitter filter
bin_data=randi(1,SigLen);
%generating prbs of length SigLen
data_format=2*bin_data-1;
% BPSK constillation
t=Tsamp:Tsamp:Tb*SigLen;
% time vector
carrier_signal=sqrt(2*Eb/nsamp)*sin(2*pi*fc*t);
% carrier signal
bin_signal=conv2(Tx_filter,upsample(data_format,nsamp),'shape');
%bin_signal=rectpulse(OOK,nsamp);
% rectangular pulse shaping
bin_signal=bin_signal(1:SigLen*nsamp);
Tx_signal=bin_signal.*carrier_signal;
% transmitted signal
Eb_N0_dB=-3:10;
% multiple Eb/N0 values
for ii=1:length(Eb_N0_dB)
Rx_signal=awgn(Tx_signal,Eb_N0_dB(ii)+3-10*log10(nsamp),'measured');
% additive white gaussian noise
Rx_output=Rx_signal.*carrier_signal;
% decoding process
for jj=1:SigLen
output(jj)= sum(MF_output((jj-1)*nsamp+1:jj*nsamp));
% matched filter output
% alternatively method of matched filter is given in OOK
simulation
end
rx_bin_data=zeros(1,SigLen);
rx_bin_data(output>0)=1;
[nerr(ii) ber(ii)]=biterr(rx_bin_data,bin_data);
end
figure
semilogy(Eb_N0_dB,ber,'bo','linewidth',2);
hold on
semilogy(Eb_N0_dB,0.5*erfc(sqrt(10.^(Eb_N0_dB/10))),'r-X','linewidth',2);
% theoretical ber, 'mx-');
  1 commentaire
Dennis
Dennis le 30 Août 2018
Modifié(e) : Dennis le 30 Août 2018
Check the size of bin_signal before the error occurs. You want to access bin_signal(1:50000), check if that entry exists. Consider that bin_signal might be a 2D matrix and not a vector.

Connectez-vous pour commenter.

Réponses (1)

Cesar Antonio Lopez Segura
Cesar Antonio Lopez Segura le 30 Août 2018
I try to help you but my error msg is 'upsample' function is not defined.
  2 commentaires
Alexandra Diaconu
Alexandra Diaconu le 30 Août 2018
Is strange that we don't have the same errors..
Dennis
Dennis le 30 Août 2018
I think upsample is part of the signal processing toolbox.

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by