Sum(X) = 1 but Sum(X)==1 produces logical 0
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (2)
James Tursa
il 22 Lug 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
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!