find second minimum in a row in matlab without sorting
显示 更早的评论
find second minimum in a row in matlab without sorting.
excluding zero
example A = [ 3.5 2 1.6 1.456 0 1.9 2.6 ; 3.8 2.6 3.9 0 6 1.564 0 ]
3 个评论
the cyclist
2019-10-16
Sounds like homework. What have you tried?
Nitin Sapre
2019-10-17
Adam Danz
2019-10-17
Why avoid sorting?
采纳的回答
更多回答(2 个)
Ekaterina Sadovaya
2019-10-18
You can exclude the first minimum. So, for example for the first row it will be
A1 = A(1,:);
[first_min_value, index] = min(A1);
A1(index) = [];
second_min_value = min(A1);
7 个评论
...or a variation of (hint)
max(mink(A,2))
Nitin Sapre
2019-10-18
Nitin Sapre
2019-10-18
Adam Danz
2019-10-18
No need for a loop.
Here's a similar example.
x = randi(20,8,8) %Random integers between 1 and 20
% Replace all values greater than the mean.
x(x > mean(x(:))) = NaN;
Nitin Sapre
2019-10-19
Nitin Sapre
2019-10-19
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!