Find row in a matrix A corresponding to the row another matrix B

1 vue (au cours des 30 derniers jours)
Good Morning.
I hope you are well and also I hope you help me with your advice to find the solution.
I have an A matrix of 6 X 10 as an example:
-1.3726 -0.7760 -0.6715 -0.2796 -0.1499 0.1499 0.2796 0.6715 0.7760 1.3726
-1.3726 -0.7760 -0.6715 -0.1796 -0.0499 0.0499 0.1796 0.6715 0.7760 1.3726
-1.3726 -0.7760 -0.7715 -0.2796 -0.0499 0.0499 0.2796 0.7715 0.7760 1.3726
-1.3726 -0.7760 -0.6715 -0.2796 -0.0499 0.0499 0.2796 0.6715 0.7760 1.3726
-1.3726 -0.8760 -0.6715 -0.2796 -0.0499 0.0499 0.2796 0.6715 0.8760 1.3726
-1.4726 -0.7760 -0.6715 -0.2796 -0.0499 0.0499 0.2796 0.6715 0.7760 1.4726
Each row is taken for a certain operation resulting in a matrix B_ 6 X 1:
B=[13.01; 13.14; 16.60; 20.05; 13.74; 12.48]
The first row of matrix A produces the first row of matrix B
The second row of matrix A produces the second row of matrix B and so on
The problem is that through Matlab code identify the maximum value and the posicon of vector B and know what elements of the row and position of that line of matrix A corresponds to it.
In this case it is visually known that the maximum in B is 20.05 and that it occupies the 4th row of the same matrix and therefore corresponds to the fourth row of matrix A with elements that are in that row, that is: -1.3726 -0.7760 -0.6715 -0.2796 -0.0499 0.0499 0.2796 0.6715 0.7760 1.3726
That's what I want to know: value and position of the maximum of B and position and values of the elements of vector A that produced that maximum value in B
I hope you have understood me and I am waiting for your help. Thank you.

Réponse acceptée

Paolo
Paolo le 9 Juil 2018
Modifié(e) : Paolo le 9 Juil 2018
If I am understanding the question correctly the answer is simply:
>>C = A(B==max(B),:)
C = Columns 1 through 7
-1.3726 -0.7760 -0.6715 -0.2796 -0.0499 0.0499 0.2796
Columns 8 through 10
0.6715 0.7760 1.3726

Plus de réponses (1)

Ricardo Gutierrez
Ricardo Gutierrez le 9 Juil 2018
Paolo Excellent you are a genius, thank you very much

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by