Why does can't I assign number greater than 1 to a matrix?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Matthew Gingerich
le 22 Juil 2018
Réponse apportée : Paolo
le 22 Juil 2018
Why is value (2,2) of this matrix getting assigned to 1 instead of 9 in this console output? How can I make it take values greater than 1?
>> myMat = ~eye(3)
myMat =
0 1 1
1 0 1
1 1 0
>> myMat(2,2) = 9
myMat =
0 1 1
1 1 1
1 1 0
0 commentaires
Réponse acceptée
Paolo
le 22 Juil 2018
~eye(3) returns a logical array. You must convert it to double. Use:
logicalMat = ~eye(3);
myMat = double(logicalMat);
myMat(2,2) = 9;
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!