How to predefine elements of a matrix (variable) in CVX?

Uncategorized
Mar 16, 2022
B

Hi

I want to perform linear regression, but some elements of the regressor variable are already known. How do I tell cvx that it must solve for the other variables and predefine the known elements?

Example:
Y = A*X

where Y is (for instance) a 3x10 matrix, A is 3x3 and X is 3x10.

I want to minimise the 2 norm of A*X-Y.

cvx_begin quiet
    variables A(3,3) 
    minimize( norm(A*X-Y,2) )
cvx_end

I want to solve this problem , but I already know some elements of A.

Any suggestions on how to program this into cvx?

Thank you in advance!

J

Use equality constraints like A(1,2)==3;.

M

Another option is to build up the matrix using concatenation to form A as an expression.

variable x(5)
A = [1 2 x(1);x(2) 4 x(3);x(4) -2 x(5)];
B
Replying to #3

Yes that would work! But what if my variables are changing between replications (e.g. A(1,1)=x(1))? Or what if my A matrix is large? Is there a way to automate this?

M

If you provide the specifics of a problem of interest, perhaps a poster can provide more specific advice.

B
Replying to #5

I figured out a way to do this. Thanks anyways!