How to delete some specific rows of a column vector simultaneously?
4 次查看(过去 30 天)
显示 更早的评论
% C2
A = [12
14
24
26
15
11
18
14 ];
A is a column vector. I want a small one-line code/command to delete only 2nd, 5th and 8th rows of A simultaneously. Basically I want to delete those rows in one go/ one run.
0 个评论
回答(1 个)
Walter Roberson
2021-6-30
ARRAY(ARRAY==VALUE) = []; %delete if array is exactly value
or
NEW_ARRAY = ARRAY(ARRAY~=VALUE) %create new vector without disturbing old one
or
ARRAY(ismember(ARRAY, [LIST OF VALUES])) = [] %delete if value is any of the ones in the list of values
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!