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
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Akzeptierte Antwort
KSSV
am 23 Nov. 2021
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 ;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!