필터 지우기
필터 지우기

append elements to a vector

조회 수: 26 (최근 30일)
Salvatore Mazzarino
Salvatore Mazzarino 2012년 11월 8일
At the beginning of my simulation I create an empty vector
vector = []
During the simulation I insert some elements into this vector. The elements could be repeated. How can I append elements to this vector without deleting the existing elements?

채택된 답변

Matt Fig
Matt Fig 2012년 11월 8일
편집: Matt Fig 2012년 11월 8일
The usual way to do it is something like this.
v = [];
for ii = 1:3
v = [v ii:4];
end
v % Show v
Note that it is usually better to avoid growing an array in a loop if possible. But one would have to see the code to know if it should be avoided.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by