フィルターのクリア

Deleting All the Rows with values Bigger or equal than 10

11 ビュー (過去 30 日間)
Fabio Taccaliti
Fabio Taccaliti 2022 年 7 月 6 日
コメント済み: Fabio Taccaliti 2022 年 7 月 6 日
Hello,
I have an array Output (2106x).
I would like to delete all rows from it it the value in the fourth column is greater or equal than 10.
My idea was to create a for loop that checked all the values in the fourth column and if the value was bigger than 0 than the entire corresponding row is deleted.
Is this approach the fastest or should I do in another way?
I tried this but this is not working, where I'm wrong?
I think the problem is that is doing the look on the length of the original Output array, but since then is deleting the elements, the array length is smaller, and the program cannot deal with it
for i=1:length(Output(1,4))
if Output(i,4) >= 10
Output(i,:) = [],
end
end

採用された回答

Walter Roberson
Walter Roberson 2022 年 7 月 6 日
mask = Output(:,4) >= 10;
Output(mask,:) = [];
  1 件のコメント
Fabio Taccaliti
Fabio Taccaliti 2022 年 7 月 6 日
Thanks Walter, this is working :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by