Index exceeds the number of array elements Index must not exceed 634 error digital signal processing
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Saarthak Gupta
2023-11-29
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:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!