Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Find the highest possible value in a matrix that complies to a certain range
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I couldn't find a way to word my question better since English is not my native language.
For example I have this matrix A = [1 2 3; 2 2 4; 3 2 5; 4 2 6]
I want to display the elements of the lowest row in which the value of third element is < 7
So in this example, the values would be 4 and 2 and because they are the lowest row and 6 is still smaller than 7.
댓글 수: 1
답변 (1개)
Domanic
2018년 1월 26일
I think I understand your question. You are interested in the row which is closest to the bottom of the matrix ('lowest' in that sense). These are actually rows with the highest index. A one line solution is:
A(find(A(:,3)<7,1,'last'),1:2)
This finds the row index of the last element of the third column of matrix, A, which has a value less than 7. Then, it displays the first two columns of the row with that index. Hope that helps.
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!