picking rows which has negative element.
조회 수: 6 (최근 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에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!