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!