Floating point numeric problem
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Qian Feng
am 9 Dez. 2016
Kommentiert: Star Strider
am 17 Dez. 2016
I encounter a problem which I cannot understand.
a = 1.228269:0.000001:1.22828;
b = 1.228265:0.000001:1.22828;
ismember(a,b)
>> ismember(a,b)
ans =
1×12 logical array
0 1 0 1 1 1 1 1 1 1 1 1
It is clearly to see that the logical array is not compatible with the values in vectors a and b. An expert has suggested that this has to do with the floating point numerics, do anyone can explain what happened to this example and how to we circumvent it ? Thanks a lot !
0 Kommentare
Akzeptierte Antwort
Star Strider
am 9 Dez. 2016
You can circumvent it using the ismembertol function (in R2015a and later versions).
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!