How to create an array which changes with each iteration of a loop?

1 visualización (últimos 30 días)
How to create an array which changes with each iteration of a for loop? for example;
polyX(i)=horzcat(X2(i),X1(i+1),V(i+1));
polyX is an array.

Respuesta aceptada

Star Strider
Star Strider el 12 de Nov. de 2016
It is not certain what you want to do. We don’t know what scalars or arrays you’re concatenating, so I would create ‘polyX’ as a cell array, since cell arrays are much more tolerant of changing dimensions than matrices:
polyX{i} = horzcat(X2(i),X1(i+1),V(i+1));
Note the curly braces ‘{}’ denoting that ‘polyX’ is now a cell array. See the documentation on Cell Arrays for details.
  4 comentarios
KalMandy
KalMandy el 12 de Nov. de 2016
Thank you very much, Your explanations are very easy to follow!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by