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!