How do I delete a row based on the based of the first column cell?
1 回表示 (過去 30 日間)
古いコメントを表示
For example. If I wanted to delete each row that contained the number 10 in the first column, how can I do that. Essentially is acts like a filter and deletes all the rows with that value.
0 件のコメント
採用された回答
the cyclist
2012 年 6 月 28 日
If x is your array,
x(x(:,1)==10,:) = [];
2 件のコメント
Ryan
2012 年 6 月 28 日
編集済み: Ryan
2012 年 6 月 28 日
x(:,1) == 10 returns a logical vector (1 for a 10, 0 otherwise). He's searching all rows (:,) and just the first column (,1).
x(logical vector,:) is locating the row's that have the 10 in the first column from before (dictated by the x(:,1) == 10) and saying select all the columns (,:) of those rows and then delete them by setting them equal to [].
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!