Looping through index number + 1
Mostrar comentarios más antiguos
Hello, say I have a cell array called 'group' and I want to loop to do a specific calculation which is the following:

In this case, i goes from 1 to 15 and I am calculating the norm between each cell subarray, 1st row.
So when i = 15, where my code has i+1 this would be 16 and it would exceed the index number of array elements.
What would be the best way to avoid this issue? Using an if statement when i == 15?
Thanks.
Respuesta aceptada
Más respuestas (1)
Antoni Garcia-Herreros
el 28 de Mzo. de 2023
Not exactly sure what you are trying to do but, why do you want to loop through all 15 cells? isn't it enough to loop through 14?
for i=1:size(group)-1 % This only loops 14 times
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!