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

조회 수: 4 (최근 30일)
Alexandra Diaconu
Alexandra Diaconu 2018년 8월 30일
댓글: Dennis 2018년 8월 30일
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
Dennis
Dennis 2018년 8월 30일
편집: Dennis 2018년 8월 30일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Cesar Antonio Lopez Segura
Cesar Antonio Lopez Segura 2018년 8월 30일
I try to help you but my error msg is 'upsample' function is not defined.
  댓글 수: 2
Alexandra Diaconu
Alexandra Diaconu 2018년 8월 30일
Is strange that we don't have the same errors..
Dennis
Dennis 2018년 8월 30일
I think upsample is part of the signal processing toolbox.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 ASK에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by