Newbie: How to find and delete the min element of a matrix??
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Andrei Bobrov
le 4 Juin 2012
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!