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

7 次查看(过去 30 天)
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