필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
KalMandy
KalMandy 2016년 11월 12일
댓글: Star Strider 2016년 11월 12일
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
KalMandy
KalMandy 2016년 11월 12일
Thank you very much, Your explanations are very easy to follow!
Star Strider
Star Strider 2016년 11월 12일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (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