How to set -0.0000 and 0.0000 as zero in matlab?
Afficher commentaires plus anciens
By a long calculation I get this array
A1 =
Columns 1 through 13
-0.0000 0.2825 -0.0000 -0.4251 0.0000 1.8665 -0.0000 -0.4917 -0.0000 -1.2564 -3.0573 0.0000 0.9482
Columns 14 through 24
-0.0000 -0.0000 -0.1321 1.8201 -1.2423 -0.0000 0.5664 -0.0000 0.0816 -0.6590 -0.0000
I want to change each element that is greater than zero as 1, smaller than zero as -1 and zero remains zero but matlab is cosnidering 0.0000 and -0.0000 as 1 too. Like this
Z = -(A1<0) + (A1>0)
Z =
Columns 1 through 21
-1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1
Columns 22 through 24
1 -1 -1
Is there a way to keep zeros as zeros? Please help
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!