minimum output matrix from data
2 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
Ive J
2021 年 1 月 11 日
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]
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!