How to implement dynamic looping of minimize

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

For instance, Could L21 norm be built in objective function? - #2 by Mark_L_Stone