Extract the row that contains the minimum value in the last column of a matrix

19 ビュー (過去 30 日間)
Ayoub Ghorbel
Ayoub Ghorbel 2021 年 7 月 29 日
回答済み: Chunru 2021 年 7 月 29 日
Given a matrix A of shape (m,n), I want to find the minimum value in the last column of A and extract the row that contains that minimum. How can I do that?

採用された回答

Chunru
Chunru 2021 年 7 月 29 日
A = randn(4, 5)
A = 4×5
0.5822 -0.8250 0.5723 -1.1310 0.5038 -2.0337 0.7604 -0.0819 0.4685 -0.2146 1.0361 0.2936 0.0097 0.2982 0.5235 0.1029 1.5128 -0.8380 -0.3989 0.0932
[~, irow] = min(A(:, end));
b = A(irow, :)
b = 1×5
-2.0337 0.7604 -0.0819 0.4685 -0.2146

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by