MATLAB: Random dot product tricks

dotfliplrsort

Greetings again,
I have two arrays:
x = [1.3, 5.6, 7.8, -6.5, 0.3]
y = [134.2, 8786.98, -22.4, 4553518.6, 0.0019]
Now, I know how to do the dot product
a=dot(x,y)
and the reverse (i.e, the first dot product has the summation from 1 to 5, but the reverse is 5 to 1),
so
xback = fliplr(x);
yback = fliplr(y);
b=dot(x,y)
but what about largest-to-smallest order dot produc? Is there anyway to organize that in MATLAB from the original arrays?
I didn't know if this was with the sort command.
Thanks!

Best Answer

xy = x.*y;
dotxy = sum(sort(xy(xy>0), 'descend')) + sum(sort(xy(xy<0)));