a matrix times a matrix returns a matrix even if it is 1x1. (I'm not checking for this case). If it is 1x1 !!sC=(trans(mA)*mB)(1,1); should do the trick for you.