I have the above loop running on the above variables:
- A is a 2d array of size mxn.
- mask is a 1d logical array of size 1xn
- results is a 1d array of size 1xn
- B is a vector of the form mx1
- C is a mxm matrix, m is the same as the above.
Edit: expanded foo(x) into the function.
here is the code:
temp = (B.'*C*B);
for k = 1:n
x = A(:,k);
if(mask(k) == 1)
result(k) = (B.'*C*x)^2 / (temp*(x.'*C*x)); %returns scalar
end
end
take note, I am already successfully using the above code as a parfor loop instead of for. I was hoping you would be able to suggest some way to use meshgrid or the sort to yield better performance improvement. I don't think I have RAM problems so a solution can also be expensive memory wise.
Many thanks.
fooadmit a matrix input, or only columns?result. Changeif(mask(k) == 1)toif mask(k). You won't get much gain from that, though.fooexample?A(k,:)in the code and notA(:,k)...