finding the second and the third smallest value in a cell array
19 次查看(过去 30 天)
显示 更早的评论
A = num2cell(reshape(randperm(12)-6,[],2),2);
mn = cellfun(@(x) min(x(x>0)),A,'Un',0);
mn = min([mn{:}]) % Show the minimum positve value.
L = cellfun(@(x) find(x==mn),A,'Un',0);
idx = find(~cellfun('isempty',L),1,'last') % Which cell has the min.
L = L{idx} % And the positions
mn = min([mn{:}]) How can I rewrite this line so I get the second smallest value and third smallest value in that table of mins.
thanks
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!