Does it really, really, really matter? Actually, there is a (subtle) reason for the 2.0.
You should recognize there is some potential ambiguity in the subexpression
2.*x
Was that intended to be seen as the number 2. multiplied by x using the .* operator, or the integer 2, multipled, using the * operator? And yes, you might decide the difference is not relevant. But might it be relevant? For example:
How should this line be evaluated?
x*2.*x'
ans =
2 4 6 8 10
4 8 12 16 20
6 12 18 24 30
8 16 24 32 40
10 20 30 40 50
In terms of the order of operations, MATLAB will multiply x. by 2. Then it needs to multiply that result by the vector transpose(x). But should it use the .* operator? Or the * operator? That is, should the result be:
(x*2).*(x')
ans =
2 4 6 8 10
4 8 12 16 20
6 12 18 24 30
8 16 24 32 40
10 20 30 40 50
In MATLAB, this operation would yield a 5x5 array. But the alternative would be written as
And that operation yields a scalar.
The thing is, it very much matters how you interprret that line. Now, consider the expression:
Now there can be no ambiguity, since we know that 2.0 is the number 2. AND that the operator that follows is the .* operator.
Looking at the code you have, again, the 2.0 should always eliminate any confusion.