# How to implement dynamic looping of minimize

I need to minimize the L2,1 norm of a matrix,that is ||X||_{2,1}=\sum_i(\sum_j x_{ij}^2)^{\frac{1}{2}},
I tried many methods to no avail, but finally found a method, but this method only worked in the beginning and not in subsequent iterations.
If X is a 100 by 8 matrix，Then the way I implement L2,1 norm is like this
minimize( norm(X(1,:),2)+norm(X(2,:),2)+norm(X(3,:),2)+norm(X(4,:),2)+norm(X(5,:),2) …
+norm(X(6,:),2)+norm(X(7,:),2)+norm(X(8,:),2)+norm(X(9,:),2)+norm(X(10,:),2) …
+norm(X(11,:),2)+norm(X(12,:),2)+norm(X(13,:),2)+norm(X(14,:),2)+norm(X(15,:),2) …
+norm(X(16,:),2)+norm(X(17,:),2)+norm(X(18,:),2)+norm(X(19,:),2)+norm(X(20,:),2) …
+norm(X(21,:),2)+norm(X(22,:),2)+norm(X(23,:),2)+norm(X(24,:),2)+norm(X(25,:),2) …
+norm(X(26,:),2)+norm(X(27,:),2)+norm(X(28,:),2)+norm(X(29,:),2)+norm(X(30,:),2) …
+norm(X(31,:),2)+norm(X(32,:),2)+norm(X(33,:),2)+norm(X(34,:),2)+norm(X(35,:),2) …
+norm(X(36,:),2)+norm(X(37,:),2)+norm(X(38,:),2)+norm(X(39,:),2)+norm(X(40,:),2) …
+norm(X(41,:),2)+norm(X(42,:),2)+norm(X(43,:),2)+norm(X(44,:),2)+norm(X(45,:),2) …
+norm(X(46,:),2)+norm(X(47,:),2)+norm(X(48,:),2)+norm(X(49,:),2)+norm(X(50,:),2) …
+norm(X(51,:),2)+norm(X(52,:),2)+norm(X(53,:),2)+norm(X(54,:),2)+norm(X(55,:),2) …
+norm(X(56,:),2)+norm(X(57,:),2)+norm(X(58,:),2)+norm(X(59,:),2)+norm(X(60,:),2) …
+norm(X(61,:),2)+norm(X(62,:),2)+norm(X(63,:),2)+norm(X(64,:),2)+norm(X(65,:),2) …
+norm(X(66,:),2)+norm(X(67,:),2)+norm(X(68,:),2)+norm(X(69,:),2)+norm(X(70,:),2) …
+norm(X(71,:),2)+norm(X(72,:),2)+norm(X(73,:),2)+norm(X(74,:),2)+norm(X(75,:),2) …
+norm(X(76,:),2)+norm(X(77,:),2)+norm(X(78,:),2)+norm(X(79,:),2)+norm(X(80,:),2) …
+norm(X(81,:),2)+norm(X(82,:),2)+norm(X(83,:),2)+norm(X(84,:),2)+norm(X(85,:),2) …
+norm(X(86,:),2)+norm(X(87,:),2)+norm(X(88,:),2)+norm(X(89,:),2)+norm(X(90,:),2) …
+norm(X(91,:),2)+norm(X(92,:),2)+norm(X(93,:),2)+norm(X(94,:),2)+norm(X(95,:),2) …
+norm(X(96,:),2)+norm(X(97,:),2)+norm(X(98,:),2)+norm(X(99,:),2)+norm(X(100,:),2) …
);

Although this is very cumbersome, it can still be achieved.

This method is only suitable for initializing X_0，After that I will take certain rows from X to minimize, this step is what confuses me the most,If it cannot be made to automatically loop, I will have to manually find the support set T_l at each step and manually modify the expression of minimize。

Then I thought of a way。
expression Z(n);
for i =1:n
Z(i)=norm(X(i,:),2);
end

but the answer is different when you minimize（Z（1）） and minimize(norm(X(1,:),2))

This makes me unable to proceed, so I would like to know if there is any way to achieve it.

You should be able to do what you want using sum, norms, and proper indexing, adapting as necessary for your problem.

Yes, I have figured out whether I can implement L2,1 norm, but what I want is whether I can minimize(X_(T)
) where T is a set.

You can only minimize a scalar number.

if you are trying to implement Algorithm 1, you need to call CVX within a while loop. I don’t know how supp is calculated, or what the resulting T_l looks like. But if that is some set of rows or columns, presumably you need to index properly into X before taking The L2,1 norm. That’s what I was alluding to by mentioning proper indexing. Figuring out those details is out of scope of this forum, and is your responsibility as someone who is implementing an algorithm.