How to remove rows based on logical values in one column?

21 visualizaciones (últimos 30 días)
Mahyar Farahani
Mahyar Farahani el 3 de Oct. de 2020
Respondida: Image Analyst el 3 de Oct. de 2020
Hi
In my file I have 3 columns with many rows. One of the columns has 0/1 logical vlaues, I was wondering if there is command to remove all the rows associated with value 0 and keep all the one that are 1?

Respuestas (2)

madhan ravi
madhan ravi el 3 de Oct. de 2020
T = table2array(readtable('73(4)_interval.xlsx'));
T(any(T==0, 2), : ) = []

Image Analyst
Image Analyst el 3 de Oct. de 2020
Let's say column 2 is the one you want to inspect, and data is your matrix. Then you can do
data = readmatrix(filename);
goodRows = logical(data(:, 2)); % Get column 2.
data = data(goodRows, :); % Take only rows where column 2 is 1.
Just basic MATLAB vectorization.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by