I thought maybe you could use an approach similar to my post in Building Functions using CVX , but that doesn’t seem to work with variable declarations
I don’t know how “efficient” this is, but one possibility is to declare a single 3D array
variable giant_array(max_num_rows,max_num_columns,num_matrices)
in which the max_num_rows
and max_num_cols
are respectively the maximum of the number of rows and number of columns across all num_matrices
matrices.
If matrix k is i by j, then just use giant_array(1:i,1:j,k) in the remainder of your CVX program. I think that the unused portions of giant_array
never go to the solver, but I guess they do use up some memory in CVX processing.