MATLAB Answers

Robert
0

Extracting info from multiple matrices

Asked by Robert
on 17 Nov 2018
Latest activity Commented on by madhan ravi
on 17 Nov 2018
Hello,
Wondering if anyone could suggest a simple way to extract info from matrix B based on Matrix A. I have two "correponding" matrices, info in Matrix A relate to info in Matrix B:
A=[1.02 0.2; 2.2 0.4; 0.5 0.6; 4.8 0.5; 1.5 0.3];
B=[58 63 27 1 478];
In this case, I need to identify the maximum value in Matrix A column 2, and then extract the associated info from Matrix B
Maxi=max(A(:,2));
Maxi =0.6, which correspond to 3rd row of Matrix A, and the to 3rd row of Matrix B, or in this case the value = 27
This is a very simple example, as my matrices are very large.
Your suggestions are very appreciated.

  0 Comments

Sign in to comment.

1 Answer

Answer by madhan ravi
on 17 Nov 2018
Edited by madhan ravi
on 17 Nov 2018
 Accepted Answer

A=[1.02 0.2; 2.2 0.4; 0.5 0.6; 4.8 0.5; 1.5 0.3];
B=[58 63 27 1 478];
[value,idx]=max(A(:,2))
B(idx) %corresponding value in B

  2 Comments

Thank you for your quick response, very appreciated!

Sign in to comment.