MATLAB: How to calculate this formula

I have a vector of weight w(1,n) and a vector of correlation p(n,1). How can calculate this formula?

Best Answer

See if this works:
wij = triu(bsxfun(@times, w, w'));
num = wij*p;
den = sum(wij(:));
pr = sum(num(:))/den);
Related Question