replace maximum values of each row of a matrix
9 views (last 30 days)
Show older comments
I have a huge matrix with i rows and j columns. I would like to find the max number for each row and, then, replace 1 in these positions and 0 in the other ones. For instance, I have matrix A
A = [1 4 3 0 ;6 0 5 9; 0 1 7 1 ; 1 5 3 1]
and I would like to produce matrix B.
B = [0 1 0 0 ;0 0 0 1; 0 0 1 0; 0 1 0 0]
I would like to have a code without using loops, as I am able to do it but the procedure time ts too long
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!