フィルターのクリア

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 Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by