https://nl.mathworks.com/matlabcentral/answers/389993-loop-through-a-vector-with-changing-legth
Loop through a vector with changing legth - MATLAB Answers - MATLAB Central
Loop through a vector with changing legth. Learn more about loop, for loop
loopvectorchangingmatlabanswers