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
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 ;
  1 个评论
Adil Sardar
Adil Sardar 2021-11-24
Thank you..
This output is from simulink I saved it in a file.. Instead of saving it how to apply this method in simulink for running time so that I get the output in binary format.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by