Finding maximum value of a column in a matrix

조회 수: 51 (최근 30일)
Chiamaka Agwuegbo
Chiamaka Agwuegbo 2017년 6월 26일
댓글: raqib Iqbal 2020년 7월 3일
Hello, I would really appreciate any help I can get here. I have a 3x5 matrix, A= [4 9 7 8 8; 2 1 0 3 5; 6 3 3 2 1]. I want to find the maximum value in column 1 and have the output display the corresponding row values of that maximum value. That is B = [6 3 3 2 1]. Please how can I achieve that? Thank you.

채택된 답변

James Tursa
James Tursa 2017년 6월 26일
[~,x] = max(A(:,1));
B = A(x,:);
  댓글 수: 4
Chiamaka Agwuegbo
Chiamaka Agwuegbo 2017년 6월 26일
Thank you Andrei. It worked perfect.
raqib Iqbal
raqib Iqbal 2020년 7월 3일
How to run this in a loop like after finding max value of column1 ,it will display and den find the next max value from that same column1?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by