a = [0.1,0.1,0.1,0.3,0.2,0.1,0.1,0,0]
a =
Columns 1 through 8
0.1000 0.1000 0.1000 0.3000 0.2000 0.1000 0.1000 0
Column 9
0
sum(a)
ans =
1
sum(a) - 1
ans =
0
b = [0.2,0.1,0.1,0.3,0.1,0.1,0.1,0,0]
b =
Columns 1 through 8
0.2000 0.1000 0.1000 0.3000 0.1000 0.1000 0.1000 0
Column 9
0
sum(b)
ans =
1.0000
sum(b) - 1
ans =
-1.1102e-16
a 矩阵中两个数调换位置得到 b矩阵,为什么对其求和的答案不一样?? 而且经过试验,发现只有矩阵[0.2,0.1,0.1,0.3,0.1,0.1,0.1,0,0]有这样的情况,难道是我的MATLAB的问题?
数值计算的问题,浮点数就是这个样子的,跟matlab无关
正常情况正常情况正常情况