Filter löschen
Filter löschen

minimum output matrix from data

1 Ansicht (letzte 30 Tage)
ANAND ASP
ANAND ASP am 11 Jan. 2021
Beantwortet: Ive J am 11 Jan. 2021
i have A matrix and i want B matrix as output
A=[ 0 2.8284 5.6569;
2.8284 0 2.8284;
5.6569 2.8284 0;
1.4142 3.1623 5.8310;
5.0000 2.2361 1.0000]
B=[1 1;
2 2;
3 3;
4 1;
5 3]
logic is, In 1st row has minimum number is 0, zero belongs to 1st column so output is 1
In 2nd row has minimum number is 0, zero belongs to 2st column so output is 2
In 3rd row has minimum number is 0, zero belongs to 3st column so output is 3
In 4th row has minimum number is 1.4142, 1.4142 belongs to 1st column so output is 1
In 5th row has minimum number is 1, 1belongs to 3st column so output is 3
in B martrix 1st column is serial number and 2nd column is output.

Akzeptierte Antwort

Ive J
Ive J am 11 Jan. 2021
A=[ 0 2.8284 5.6569;
2.8284 0 2.8284;
5.6569 2.8284 0;
1.4142 3.1623 5.8310;
5.0000 2.2361 1.0000];
[~, minIdx] = min(A, [], 2);
B = [(1:size(A, 1))', minIdx]

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by