フィルターのクリア

How to set the maximum value of a column in a matrix to 1 and other values to 0?

3 ビュー (過去 30 日間)
Kanak Jain
Kanak Jain 2018 年 8 月 2 日
回答済み: Stephen23 2018 年 8 月 2 日
For example: if the matrix is given as:
1 6 3 6
2 5 6 7
6 4 3 10
It should look like this:
0 1 0 0
0 0 1 0
1 0 1 1
That is, the maximum value of the column in the matrix should become 1 and the other values if the column should become zero.

回答 (1 件)

Stephen23
Stephen23 2018 年 8 月 2 日
>> +bsxfun(@eq,M,max(M,[],1))
ans =
0 1 0 0
0 0 1 0
1 0 0 1

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by