Matrix index is out of range for deletion

3 vues (au cours des 30 derniers jours)
sasson vaknin
sasson vaknin le 28 Oct 2020
Hi
Im using EEGLAB toolbox for preprocess my data.
one step in my preprocessing is to remove manually some noisy segments of the data.
When Im using the removing function i have no problem at all, but when Im using my code on a multiple subjects i get the error below:
the part of the code which stack when applied on multiple subjects:
any suggestions?

Réponses (1)

Walter Roberson
Walter Roberson le 28 Oct 2020
You have a loop in which you move forward through the loop, deleting entries if some condition matches.
However, every time you delete something, everything after that in the same array "falls down" to fill the hole, sort of like in Tetris. And so all of the positions you had calculated for anything after that become invalid, because the corresponding data entries have moved forward in the array by size corresponding to what you deleted.
The easiest way to fix this kind of problem is not to loop forward deleting as you go, but instead to move backwards deleting as you go. The positions for anything before for deletion point will not be changed by having deleted afterwards, so you do not need to update anything in the positions.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by