How to display the Index of a matrix to other corresponding matrices

3 views (last 30 days)
Hi All,
Please can you help me solve this problem?
I have 3 different matrices
A=[8 3 5;2 4 6;9 3 4]
B=[4 11 5;9 3 2;4 8 1]
C=[11 40 3;10 7 5;11 3 60]
My mimimum value in matrix A=2 (i.e row 1 column 2). Now the question is how do i make the corresponding matrices of B & C to automatically display their values of row 1 and column 2 which is B=9, C=10?
Thank you

Accepted Answer

Stephen23
Stephen23 on 9 Feb 2021
Edited: Stephen23 on 9 Feb 2021
A = [8,3,5;2,4,6;9,3,4]
A = 3×3
8 3 5 2 4 6 9 3 4
B = [4,11,5;9,3,2;4,8,1]
B = 3×3
4 11 5 9 3 2 4 8 1
C = [11,40,3;10,7,5;11,3,60]
C = 3×3
11 40 3 10 7 5 11 3 60
[v,x] = min(A(:));
B(x)
ans = 9
C(x)
ans = 10
Or without reshaping A:
[v,x] = min(A,[],'all','linear');

More Answers (1)

KSSV
KSSV on 9 Feb 2021
[val,idx] = min(A(:))
B(idx)
C(idx)

Tags

Community Treasure Hunt

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

Start Hunting!