How to get row indices of negative values

5 visualizaciones (últimos 30 días)
Mekala balaji
Mekala balaji el 5 de Jun. de 2019
Editada: Matt J el 5 de Jun. de 2019
Hi,
I have cell matrix and I want to identify the rows whose value is negative in the column name "score", and delete entire row if value in this column is negative.
date Name score categoty rank
20-03-2019 10:24 VAGB -0.12 0 1.0
20-03-2019 11:10 KALI 97 0.15 1.3
20-03-2019 13:13 VAGB -1.9 0.53 1.5
24-03-2019 22:19 PART 92 2.53 1.3
27-03-2019 20:32 VAGB -12 3.0 0.96
27-03-2019 23:42 NCRTY 86 3.21 1.5

Respuestas (1)

Matt J
Matt J el 5 de Jun. de 2019
Editada: Matt J el 5 de Jun. de 2019
T=readtable('inpudata.csv');
T=T(T.score>0,:)
  2 comentarios
Mekala balaji
Mekala balaji el 5 de Jun. de 2019
This works, but in some matlab versions readtable is not available. I want to use cellfunction.
I use below code, but it give error.
index = cellfun(@(x), rawData(:,3), 'UniformOutput', 1);
Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.
Matt J
Matt J el 5 de Jun. de 2019
Editada: Matt J el 5 de Jun. de 2019
The same kind of thing works for cell arrays
scores=cell2mat(rawData(:,3));
T=rawData(scores>0,:)

Iniciar sesión para comentar.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by