First, rearrange your equation:
H b0 - M(Q+1) B(Q+1) - M' B = l
Now, you can concatenate variables. You will end up with an unknown vector (X
) of size 42 + 21 + 4 = 67. And a coefficient matrix (A
) of size 42 x 67
X = [b0; B(Q+1); B ]; % <- don't need to execute this; just shows alignment
A = [ H, -M(Q+1), -M'];
Now you have an equation of the form:
A X = l
Now you can solve this in a least-squares sense with the \
operator:
X = A \ l
This X
can be turned back into b0
, B(Q+1)
, and B
using the identity above in reverse:
b0 = X(1:42);
B(Q+1) = X(43:63);
B = X(64:67);