How to get row indices of negative values

2 ビュー (過去 30 日間)
Mekala balaji
Mekala balaji 2019 年 6 月 5 日
編集済み: Matt J 2019 年 6 月 5 日
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 Center および File ExchangeCreating 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