Sum(X) = 1 but Sum(X)==1 produces logical 0
Afficher commentaires plus anciens
Can someone please explain this?
sum([Node(temp).pbelief])
ans =
1.0000
K>> sum([Node(temp).pbelief])==1
ans =
0
By the way:
Node(temp(1)).pbelief
ans =
0.0024
K>> Node(temp(2)).pbelief
ans =
0.9976
Réponse acceptée
Plus de réponses (2)
James Tursa
le 22 Juil 2014
Note that when a number is exactly an integer, and you are only printing one scalar value, MATLAB prints it without any trailing 0's. But if the number is not exactly an integer, MATLAB will print trailing 0's, indicating that there is a non-zero digit down the line somewhere even if it is not printed to the screen. E.g.,
>> format short
>> 1
ans =
1
>> 1.0000001
ans =
1.0000
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!