Cyclic reading in a vector
Mostrar comentarios más antiguos
Hi, I'm a beginner and I have tried to find the solution on internet with no results
Starting from a vector=[1;2;...;x] and a for loop n=1:x,
for each loop i want to read the elements in the vector in position "n-1", "n", "n+1" at same time.
The problem is for n=1 i need to read the values in position "x" "1" "2" and for n=x i need to read the values in position "x-1" "x" "1". Now i'm working in the for loop using 3 "if" to manage the operations the 3 cases (n=1, n=x, n=all the rest), or creating a new vector =[x;1;2 ...;x;1]
Is there a better solution? Thanks
Respuesta aceptada
Más respuestas (0)
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!