Finding rows/indices by comparing individual elements of rows of one matrix to another
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
Let's say I have a 
 matrix and a 
 matrix as follows:
 and I want to find the indices of rows in 
 such that the row elements are less than the row elements of 
: e.g., in the third row, 1<2 and -2<1. I can do this by the following code:
[row,col] = find(m1(:,1)<=m2(1,1) & m1(:,2)<=m2(1,2));
The code therefore identifies row 3 and row 4 from 
. 
My question is: if I had more columns, how could I implement the same action but without using "&" everytime to define the conditions for each column as I did in my code? I am basically asking for a generalized version of what I have done.
I hope I was clear with my question. Thanks in advance!
댓글 수: 0
채택된 답변
  Tommy
      
 2020년 5월 29일
        For less than or equal to:
find(all(m1 <= m2, 2))
For less than:
find(all(m1 < m2, 2))
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!