Once you have made the matrix variables XX,YY,ZZ, those are the ones you use for further calculation, no longer x,y,z. (Notationally, you could create the matrices with names x,y,z so as to not have to use the more cumbersome XX etc. further on down). In addition, you have not made use of the position of the charge. It's the displacements from the charge location that matter. Displacements in the x direction are XX-x0, etc. All of this becomes
x0 = 1;
y0 = 1;
z0 = 4;
Ex = Q*C*(XX-x0)./r.^3;
Several times ./ and .* are required, for element-by-element multiplication of variables.