MATLAB: Question about the summation of array of elements with complex double

complexdoubleMATLABsumsymbolicSymbolic Math Toolbox

Hi there, I have a strange problem when doing the summation for my array.
I got a array of 1×64 complex double. I would like to calculate the sum of those 64 elements.
However the result come out was quite strange and I don't know where I got wrong….
'sle' is the name of the data.
I did try with real(sle) and imag(sle). Although real(sle) did give me kind of a sensible answer(I suppose), in imag(sle) from element 33 to element 40 did show a imaginary value. Which is strange because when I look back at the data, there was no corresponding imaginary numbers that present in sle.
Anyone know the reason why? Please help… ><
sle =
1 7
0.1250 + 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i
8 14
0.1250 + 0.0000i -0.1250 + 0.0000i -0.1250 + 0.0000i -0.1250 + 0.0000i -0.1250 + 0.0000i -0.1250 + 0.0000i -0.1250 + 0.0000i
15 21
-0.1250 + 0.0000i -0.1250 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i
22 28
0.3750 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i
29 35
-0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i -0.1250 + 0.0000i -0.1250 - 0.0000i -0.1250 + 0.0000i
36 42
-0.1250 - 0.0000i -0.1250 + 0.0000i -0.1250 - 0.0000i -0.1250 + 0.0000i -0.1250 - 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i
43 49
0.1250 + 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i 0.1250 + 0.0000i -0.3750 + 0.0000i
50 56
-0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i -0.3750 + 0.0000i
57 63
0.3750 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i 0.3750 + 0.0000i
64
0.3750 + 0.0000i
sum(sle)
ans =
-1.7764e-15

Best Answer

sum(sym(m))