Error when using cov function in CVX


(Xx126) #1

Hi all, here’s my problem:
Error using +: Matrix dimensions must agree.
Error using cov: xc = x - sum(x,1)./m; % Remove mean

i’m trying to compute the mahalanobis distance.
My objective function is :
x=arg min||x||_1+||Ax-y||_M ,which is equal to:
x=arg min||x||_1+||L(Ax-y)||_2, where S is the covariance matrix of Ax and y, and inv(S)=L* L.
A is a m *n matrix, x is n *1 vector, y is n *1 vector.

here’s my matlab code:
cvx_begin quiet
[~,c_n] = size(tt_dat(:,ci));
variable x(alltr_num);
minimize(norm(x,1));
%%%%%%%%%%%%%%%%%%%%%%%%
subject to
norm(chol(inv(cov1([(tr_dat * x)’;tt_dat(:,ci)’])+0.00001 * eye(c_n,c_n))) * (tr_dat * x-tt_dat(:,ci)),2)<=N;
cvx_end

Can anyone help me?


(Michael C. Grant) #2

This is addressed in the FAQ.


(Xx126) #3

Thanks for your reply.
But i’m sorry that i can’t find the corresponding FAQ.


(Xx126) #4

Is it possible to compute the covariance matrix between a real affine expression vector and a constant vector?


(Michael C. Grant) #5

The specific section of the FAQ I was referring to was that CVX is limited to those functions listed in the user guide. cov is not among them. You will have to find a way to express your model using only those functions if you wish to solve it.