Delete entire rows based on one condition

조회 수: 183 (최근 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
Luna
Luna 2019년 12월 9일
편집: Luna 2019년 12월 9일
Use the fullfile path and name together for example:
readtable('C:\Users\Desktop\...\CourseworkFinalDATAEXCEL.xlsx','ReadRowNames',true);
The path is where your excel file is.
Ayush Jain
Ayush Jain 2022년 5월 29일
Thanks it worked

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by