Find position of the maximum value and then convert the row zeros and the position of the maximum value should become 1. just like in the image attach
1 次查看(过去 30 天)
显示 更早的评论
采纳的回答
KSSV
2021-11-23
A = rand(4) ;
[m,n] = size(A) ;
B = zeros(m,n) ;
[val,i] = max(A,[],2) ;
idx = sub2ind(size(A),(1:m)',i) ;
B(idx) = 1 ;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!