Effacer les filtres
Effacer les filtres

rewrite an existing matrix into a matrix with 0 and 1

3 vues (au cours des 30 derniers jours)
Leon Phung
Leon Phung le 7 Juin 2018
Modifié(e) : KSSV le 7 Juin 2018
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.

Réponse acceptée

KSSV
KSSV le 7 Juin 2018
Modifié(e) : KSSV le 7 Juin 2018
A = randi(8,10,10) ; % random matrix for demo
B = zeros(size(A)) ;
B(A>4) = 1 ;

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by