# Sparse model optimization problem

**mamrez7**(Mohammadreza Javanmardi) #1

**Mark_L_Stone**(Mark L. Stone) #2

I’m not sure what the 1,2 norm is, but presuming it can be handled by CVX, your problem should be easy to enter.

Have you read the CVX Users’ Guide http://web.cvxr.com/cvx/doc/ ? Presuming the 1,2 norm can be handled, you can enter this problem in CVX almost as you see it. If you read the Users’ Guide and try to input your problem to CVX but get stuck, then you can ask for help on your sticking point. If this is a homework problem, you’ll learn more by trying to do it yourself rather than getting a stranger on the internet to do it for you.

**mamrez7**(Mohammadreza Javanmardi) #3

1,2 norm for the matrix P is equal to "norms(norms(P,2,2),1,1) ", my problem is how to define a loop for different k values () the summation on k ) in minimizaiton function.

**Mark_L_Stone**(Mark L. Stone) #4

You can use a for loop to build up expressions.

Something along the lines of the following, or you can rearrange it as you prefer.

I have written this presuming the superscript k matrices are the (:,:,k) entry of a d by N by K array. But if d varies for each k, as you imply, then I leave it to you to adapt the code to your circumstance.

Obj = 0

for k=1:K

Obj = Obj + square_pos(norm(D(:,:,k)W(:,:,k) - X(:,:,k),‘fro’))Obj + other terms

end

Obj = 0.5

minimize(Obj)