0
votes

I am trying to use a function in Matlab which will give me the following equation:

enter image description here

The x and a values are in two matrices. I have tried almost everything, but cannot get the correct answer. Anyone who can help??

Thanks

2
Can you show examples of what you have tried? - Buck Thorn
Have you tried two for-loops, one for i and second for j, with a condition inside, for the delta? - Adiel
The deltas matrix, a_i and a_j you have already at memory, don't you? You can do two loops as you say, it is probably not the optimal answer for matlab, but that's the way. Add the codes your tried and what went wrong on them. - Werner

2 Answers

1
votes

Assuming A and X are vectors of size n x 1, you could construct that expression by writing transpose(X) * (sqrt(A * transpose(A)) .* (ones(n) - eye(n))) * X.

1
votes

Another way to do this is

a = sqrt(ain);                  % ain is your input column vector
A = a*a.';
A = A-diag(diag(A));
aresult =   x.'*A*x             % x is your (other) input column vector