matrix index is out of range for deletion

Illustration
Shanaya - 2020-07-17T12:50:41+00:00
Question: matrix index is out of range for deletion

Hello, I am trying to delete certain rows of an 1D array if a conditional statement is true. My code is:   for i = 1:length(TF) if TF(i) == 1 pitch(i) = []; end end for the length of TF (a logical array) i evaluate TF as true or false and if it is true i want to delete the value in the array called pitch at that corrasponding index. I am getting an error message that says "Matrix index is out of range for deletion." I cannot seem to fix this probem and would appreciuate any help or suggestions.

Expert Answer

Profile picture of John Williams John Williams answered . 2025-11-20

 pitch(TF == 1) = []


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!