MATLAB: More sophisticated code than a for loop with i is large

for loopsi large nularge number

Hi there I am trying to calculate a scatter matrix for some data. so basically my Eigen values are in a matrix of the form; [e11 e12 e13; e21 e22 e23; e31 e32 e33; …… e101 e102e103]
and my scatter matrix is of the form;
[e11^2 + e21^2 + e31^2 + … e101^2, e11e12 + e21e22 + … +e101e102, e11e13 + … e101e103; e11e12 + e21e22 + … +e101e102, e12+e22+e32+..e102, e12e13+e22e23+…+e102e103; e11e13 + … e101e103, e12e13+e22e23+…+e102e103; e13^2+e23^2+…+e103^2]
Now in some cases instead of n = 10 as is the case above n =in the thousadns. is there a neat way to code for this?

Best Answer

Let e = [e11 e12 e13; e21 e22 e23; e31 e32 e33; ...... e101 e102e103];
out = e.'*e;
out(2,2) = sum(e(:,2));
Related Question