Index exceeds the number of array elements Index must not exceed 634 error digital signal processing

1 view (last 30 days)
Im trying alot and I couldn't find the bug in my code its been exhausting for me, Therefore I want to ask if there anyone could help in this matter
This is my code:
clc
clear all
load config.mat
data = load('RefInputAudio.mat');
ChannelOutVec = data.ChannelOutVec';
rx = RX(config,ChannelOutVec);
bitstream2text(rx)
the output on running this at the reciever RX function should be "digital communication is fun!"
I have attached all the necessary files that im working on them.

Answers (1)

Saarthak Gupta
Saarthak Gupta on 29 Nov 2023
Hi Audai,
I understand you are getting an out-of-bounds error in your program.
Elementary debugging revealed that the out-of-bounds error is thrown while trying to index the ‘rxbits’ array in the ‘RX’ function (RX.m).
The error occurs due to faulty downsampling of the ‘rxbits’ signal. ‘rxbits’ is a 1x253243 signal, which is downsampled by a factor of 440 (config.Ts-1), yielding a 1x576 signal. While converting the (downsampled) ‘rxbits’ to a binary signal, the code tries to access its first 10000 elements, which is erroneous since ‘rxbits’ is a 1x576 signal, as stated above.
You may want to recheck the downsampling factor of the signal, or you can access only the valid elements of ‘rxbits’. Refer to the following snippet:
rxbits = sign(rxbits(1:min(numel(rxbits),config.ninfobits)));
Please refer to the following MATLAB documentation for further reference:

Community Treasure Hunt

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

Start Hunting!