How to get row indices of negative values

조회 수: 4 (최근 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 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