How to get row indices of negative values

2 次查看(过去 30 天)
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

回答(1 个)

Matt J
Matt J 2019-6-5
编辑:Matt J 2019-6-5
T=readtable('inpudata.csv');
T=T(T.score>0,:)
  2 个评论
Mekala balaji
Mekala balaji 2019-6-5
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 2019-6-5
编辑:Matt J 2019-6-5
The same kind of thing works for cell arrays
scores=cell2mat(rawData(:,3));
T=rawData(scores>0,:)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by