I have a matrix not a vector and I need the minimum value except 0 and position of minimum value in each row
help how can I find the minimum number and return it's index in each row?
1 次查看(过去 30 天)
显示 更早的评论
help how can I find the minimum number and return it's index in each row?
采纳的回答
Manoj
2014-11-13
a=[8,2,3,4,5];
[b,ix]=min(a);
ix gives you the positions and b gives the minimum value
更多回答(1 个)
Guillaume
2014-11-13
To find the minimum of a row, use:
min(m, [], 2)
Probably, the simplest way to ignore 0s is to replace them with NaNs before calling min.
m(m == 0) = nan;
[mval, mcol] = min(m, [], 2);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!