Given a set of n vectors **a**_i, I am trying to find a vector **x** to minimize the expression |**a**_1-x|^p+|**a**_2-x|^p+|**a**_3-x|^p+…+|**a**_n-x|^p, where p is greater than 1.

I am having trouble with writing this sum expression in cvx syntax. Could someone explain what is wrong with the code below? In the code I try to initialize 5 15x1 vectors in sample, and try to find the correct value of x.

sample = rand(15,5);

p=1.5;

cvx_begin

variable x(15)

minimize( sum(pow_p(abs(sample-x),p)) )

cvx_end