How to define minimum value matrix?

조회 수: 3 (최근 30일)
anil hamzacebi
anil hamzacebi 2020년 12월 8일
댓글: anil hamzacebi 2020년 12월 8일
Hello everyone, i have a 4x4 matrix and i can find the minimum values of each row.
A=[1,2,4,3; 4,3,7,13; 8,7,9,11; 16,14,2,7];
B=min(A, [], 2)
B =
1
3
7
2
But i need to create a matrix that gives me the columns chosen for minimum values. For example, for the A matrix this is;
C=[1,2,2,3];
I hope you understand the problem, and can help me. Thank you!!!
  댓글 수: 1
dpb
dpb 2020년 12월 8일
Read the doc for min carefully looking for what options you're not using...

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

채택된 답변

David Hill
David Hill 2020년 12월 8일
[~,idx]=min(A,[],2);
  댓글 수: 1
anil hamzacebi
anil hamzacebi 2020년 12월 8일
this really works, Thank you so much!!

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

추가 답변 (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