I am looking for some help with a fast loop to form a bunch of values. Given a 30-vector, x and another 30-vector which is the expected value of such data expx . I want to be able to quickly sum 30*30=90 values to form a symmetric 30x30 matrix. Here is how the (k,l)-entry of my 30x30 matrix is:
so x forms the entries on the left part of the bracket, x_i and expx is the right part, ie < x_i > for i=1,2,...,30. You don't need to worry about what values makes up these vectors, I've already determined them. Does anyone know how I should form such elements of the matrix and put them into my 30x30 matrix.
I guess I'd start off with:
M=30;
C = zeros(M);
I'm struggling to get the summation though.
why not this:
M=30;
C = zeros(M);
for k = 1:30
for l = 1:30
for i = 1:30
C(k,l) = (x(k-i+1) - expx(k-i+1)) * (x(l-i+1) - x(l-i+1));
end
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.