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

1 次查看(过去 30 天)
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.

采纳的回答

Star Strider
Star Strider 2016-11-12
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by