How can I find the maximum of a given matrix and then locate the minimum value along the row of the maximum value

3 ビュー (過去 30 日間)
e.g a =
4 2 8
5 9 1
3 10 17
maximum will be 17 for the entire array and 3 will be the min value along the row of 17.

採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 11 月 14 日
編集済み: Andrei Bobrov 2017 年 11 月 14 日
[v_max,jj] = max(max(a,[],2));
out_min = min(a(jj,:));
or
[ii,~] = find(max(a(:))==a);
out = min(a(ii,:));

その他の回答 (2 件)

mounika
mounika 2017 年 11 月 14 日
x=[4 2 8;5 9 1;3 10 17];
[M,I] = max(x(:)); % find maximum element in the entire matrix
[I_row, I_col] = ind2sub(size(x),I);% convert matrix position to matrix indices
x_min = x(I_row,:); % extract the row containing maximum value
x_min = min(x_min); % minimum of that row

VISHAL BATHRINATH
VISHAL BATHRINATH 2024 年 8 月 26 日
% creating the matrix
A =randi([1,20],5,7)
% getting the maximum value of the matrix
% to get minimum value use min() function
b = max(A)
% getting the output of the code
disp(b)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by