Delete entire rows based on one condition

226 ビュー (過去 30 日間)
Khayroon Suleyman
Khayroon Suleyman 2019 年 12 月 5 日
コメント済み: Ayush Jain 2022 年 5 月 29 日
Hello,
I am a beginner in Matlab. I have a table that has 7 columns and 240 rows.
I need to delete entire rows based on the following condition:
1. if a value of column 7 is superior than 1000 and inferior than 100 => delete this row
I have attached an image of how the datset looks like. Please help!

回答 (1 件)

Luna
Luna 2019 年 12 月 5 日
編集済み: Luna 2019 年 12 月 6 日
Hi,
Try this:
data = num2cell(randi(5000,240,7)); % sample random data in a cell array
my_Table = cell2table(data); % convert cell array to table
new_table = my_Table(~(my_Table.data7 > 1000 | my_Table.data7 < 100),:); % filter and remove
  11 件のコメント
Ayush Jain
Ayush Jain 2022 年 5 月 29 日
Thanks it worked

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by