Sum(X) = 1 but Sum(X)==1 produces logical 0
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (2)
James Tursa
el 22 de Jul. de 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
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!