필터 지우기
필터 지우기

Newbie: How to find and delete the min element of a matrix??

조회 수: 7 (최근 30일)
Usman  Ali
Usman Ali 2012년 6월 4일
helllo every one, I would like to know how can i find the min: element value in a given (m by n)matrix and then delete that whole row where this value lies. e.g if any given matrix is M= [ 2 7 9 ; 8 1 6 ; 8 5 7 ], the lowest is M(2,2). is there any command that can I apply 1st to find this position and then to delete 2nd row and re-arrange the remaining 2 rows as a new matrix without this deleted 2nd row.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 6월 4일
M= [ 2 7 9 ; 8 1 6 ; 8 5 7 ];
out = M(~any(min(M(:)) == M,2),:)
OR
[~,ii] = min(M(:));
[i1, ~] = ind2sub(size(M),ii);
out = M(setdiff(1:size(M,1),i1),:);
OR
[~,ii]= min(min(M,[],2))
out = M;
out(ii,:) = []
etc

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by