why setdiff function ignores to delete the element in the first column of an array
1 次查看(过去 30 天)
显示 更早的评论
>> w =[0.54883746334269044248968027421965, 1.5707963267948966192313216916398, 0.59916277322729276097921590697775;1.5707963267948966192313216916398, 0.7011471887975026432568455778359, 1.5707963267948966192313216916398;-0.54883746334269044248968027421965, -0.7011471887975026432568455778359, -0.59916277322729276097921590697775]
e=setdiff(w,1.5708,'stable')
w =
0.5488 1.5708 0.5992
1.5708 0.7011 1.5708
-0.5488 -0.7011 -0.5992
e =
0.5488
1.5708 (this entry should not be there, but it persists)
-0.5488
0.7011
-0.7011
0.5992
-0.5992
please let me know what change i need to make in setdiff so that the second entry in 'e' gets deleted
2 个评论
Stephen23
2020-4-3
编辑:Stephen23
2020-4-3
Because those values are not the same, and in fact none of those values can be precisely represented using binary floating point numbers that are used on all contemporary computers. Read these to know more:
You need to learn about the limits of floating point numbers. Start by reading these:
This is worth reading as well:
采纳的回答
Fangjun Jiang
2020-4-3
You've show its value is 1.5707963267948966192313216916398.
It is the floating point data precision issue.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!