Please tell me how i can find first three minimum elements in each column of a matrix?

3 次查看(过去 30 天)
Please tell me how i can find first three minimum elements in each column of a matrix?

回答(1 个)

Andrei Bobrov
Andrei Bobrov 2016-2-12
编辑:Andrei Bobrov 2016-2-12
A - your matrix.
X = sort(A);
out = X(1:3,:);
or
z = sort(A);
x = diff(z)~=0;
y = [cumsum(x).*x;zeros(1,size(A,2))];
out = reshape(z(y > 0 & y <=3),3,[]);

类别

Help CenterFile Exchange 中查找有关 Detection, Range and Doppler Estimation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by