How to get row indices of negative values

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

Risposte (1)

Matt J
Matt J il 5 Giu 2019
Modificato: Matt J il 5 Giu 2019
T=readtable('inpudata.csv');
T=T(T.score>0,:)

2 Commenti

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 il 5 Giu 2019
Modificato: Matt J il 5 Giu 2019
The same kind of thing works for cell arrays
scores=cell2mat(rawData(:,3));
T=rawData(scores>0,:)

Accedi per commentare.

Categorie

Scopri di più su Data Acquisition Toolbox in Centro assistenza e File Exchange

Prodotti

Release

R2017a

Richiesto:

il 5 Giu 2019

Modificato:

il 5 Giu 2019

Community Treasure Hunt

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

Start Hunting!

Translated by