rewrite an existing matrix into a matrix with 0 and 1

2 ビュー (過去 30 日間)
Leon Phung
Leon Phung 2018 年 6 月 7 日
編集済み: KSSV 2018 年 6 月 7 日
I have a matrix A with size 10x10 and each element is a number from 0 to 8, I want to make another matrix that has the same size as A but for the number that bigger than 4 are become 1, and from 4 to 0 are become 0.

採用された回答

KSSV
KSSV 2018 年 6 月 7 日
編集済み: KSSV 2018 年 6 月 7 日
A = randi(8,10,10) ; % random matrix for demo
B = zeros(size(A)) ;
B(A>4) = 1 ;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by