Constraining parameters using mldivide

Viewed 46

I have a matrix equation of the form AX = B. A and B are of size 1000x3 that I know. I want to cacluate X, which is a 3x3 matrix. However, some terms of this matrix are zeros and ones. i.e. X is of the form [a 0 b; 0 c d; 0 0 1];

When I calcualte X = A\B, I get good approximations for a, b, c and d, but the values that I expect to be zeros are really small numbers.

Is there a way to constrain some of the parameters to be zeros?

1 Answers

Consider solving each row independently. You technically have 3 systems of equations of the form A*x_i=b_i, for A [1000x3], x_i [3x1], b_i [1000x1].

Now, you can make x_i any shape, particularly, you can just remove the zeros (together with the vectors in A that multiply them). If you know x_3 is [k 0 m] (random example), that is the same as solving for x_3 if size [2x1] ( [k m]) and A of size [1000x2].

Don't waste computation multiplying by zero

Related