How to set -0.0000 and 0.0000 as zero in matlab?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!