I have 2 matrices which I calculated separately.
One of the matrices is Y and its size is 2x25881 and the second one is U which is made out of 2 separate vectors like this:
U = [ArrayAT ; ArrayAD]
and the size of U is 2x25881.
Now, I want to calculate the integral of (my dt = 0.001):
The way I do it is:
Y_Int_Sum = 0;
for i = 1 : length(T)
Y_Int_Sum = Y_Int_Sum + Y_Int(:,i)'*[ArrayAT(i) ; ArrayAD(i)]*dt;
end
Is there any better way to do so?
Thank you.
This is just the element-wise multiplication of Y and U, then a sum over all the elements:
Y_Int_Sum = dt * sum(sum(Y_int .* [ArrayAT; ArrayAD]))