Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Find the highest possible value in a matrix that complies to a certain range
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Respuestas (1)
Domanic
el 26 de En. de 2018
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 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!