If I want CVX to give me the pairwise differences of the elements of a vector X
, what is the most efficient way to do so? In standard MATLAB I would normally use bsxfun(@minus, X, X')
, but CVX objects do not support bsxfun
).
If X
is a column vector, this will work:
X*ones(size(X))' - ones(size(X))*X'