Delete entire rows based on one condition

185 visualizaciones (últimos 30 días)
Khayroon Suleyman
Khayroon Suleyman el 5 de Dic. de 2019
Comentada: Ayush Jain el 29 de Mayo de 2022
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!

Respuestas (1)

Luna
Luna el 5 de Dic. de 2019
Editada: Luna el 6 de Dic. de 2019
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 comentarios
Luna
Luna el 9 de Dic. de 2019
Editada: Luna el 9 de Dic. de 2019
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 el 29 de Mayo de 2022
Thanks it worked

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by