Deleting elements from vector
이전 댓글 표시
I am removing some elements from a (long) vector. I am wondering which is the faster method in general (or better per se). Removing elements directly or by assigning "truncated" vector to the old one? This is what I mean (idx_remove are logical indices):
1.
vec(idx_remove) = [];
or 2.
vec = vec(~idx_remove);
Thanks.
채택된 답변
추가 답변 (1개)
Jan
2015년 3월 10일
vec = CopyMask(vec, ~idx_remove);
The next version will allow to apply the not() implicitly, such that the calculation of a large inverted logical vector can be avoided.
카테고리
도움말 센터 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!