picking rows which has negative element.
7 次查看(过去 30 天)
显示 更早的评论
hi, i have a matrix which can have negative elements. is ther eq quick and efficient way to pick the rows if any element in the row has negative values.
Thanks
0 个评论
采纳的回答
Iman Ansari
2013-4-17
Hi
a=randn([5 5])+1
Nrows=sum(a<0,2);
a(Nrows>0,:)
2 个评论
Iman Ansari
2013-4-17
sum(a<0,2) is number of negative elements in each row. a<0 is one for negative values and 0 for others.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!