I guess I didn't notice system
at the end of the original post. (Note equation11
is repeated in it. You can use Length@system
as a check.) This is shorter:
CoefficientArrays[system, Variables[system /. Equal -> Subtract]]
It automatically figures out the variables, which okay if all the coefficients are numeric. However, the ordering might not be what you expect:
Variables[system /. Equal -> Subtract]
(*
{x1, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x2, x20, x21,
x22, x3, x4, x5, x6, x7, x8, x9}
*)
So it might be worth constructing the variable list yourself.