# Optimization of a weighted average of matrices

Given a matrix A\in\mathbb{R}^{N\times K},
I would like to do the following maximization

$$\max_z\log \det(\sum_{i=1}^N z_i a_i^Ta_i),$$

where a_i is the $i$th row of A, under other simple constraints. How do I write such cost function in cvx in a automatic fashion, without knowing a priori the matrix and the size of A?

Thanks a lot for your help!

Given A and N, you would do the following:

cvx_begin
variable z(N)
maximize(log_det(A'*diag(z)*A))