You can only specify one optimization problem between cvx_begin and cvx_end, and therefore can have only one minimize or maximize statement between cvx_begin and cvx_end. Your program has h = 50 minimize statements.

Are you trying to solve h different minimization problems? If so, then you should have the for t = 1:h outside the cvxx_begin … cvx_end. Then there will be only one optimization problem, which has one minimize statement, inside of each cvx_begin … cvx_end.

If, on the other hand, you wish to solve only one minimization problem, but such that the objective is a sum, for instance, minimize(sum(P(:,m)), then put that outside the for t=1:h loop, and before the cvx_end.