Take coefficients of the variable from a Matrix

I have a question how can I take coefficients of the variable from a matrix? for example; I have a matrix such as: A={{2a,3b,4c},{4d},{1a,1e}} variable is {a,b,c,d,e}

Now I would like to take all coefficients from that matrix to make a new matrix. Acoef={{2,3,4,0,0},{{0,0,0,0,4},{1,0,0,0,1}}

Total[D[A, {{a, b, c, d, e}}], {2}]

{{2, 3, 4, 0, 0}, {0, 0, 0, 4, 0}, {1, 0, 0, 0, 1}}


Also

Total[Transpose[Coefficient[A, #] & /@ {a, b, c, d, e}], {3}]

{{2, 3, 4, 0, 0}, {0, 0, 0, 4, 0}, {1, 0, 0, 0, 1}}


and

Transpose@Total[Coefficient[A, #] & /@ {a, b, c, d, e}, {3}]

{{2, 3, 4, 0, 0}, {0, 0, 0, 4, 0}, {1, 0, 0, 0, 1}}

• Thank you so much! Commented Feb 22, 2021 at 18:47

Another way.

A = {{2 a, 3 b, 4 c}, {4 d}, {a, e}};
(* Variables[A]=={a,b,c,d,e} *)
A /. Thread[{a, b, c, d, e} -> IdentityMatrix[5]]
% // Map[Total]


{{{2, 0, 0, 0, 0}, {0, 3, 0, 0, 0}, {0, 0, 4, 0, 0}}, {{0, 0, 0, 4, 0}}, {{1, 0, 0, 0, 0}, {0, 0, 0, 0, 1}}}

{{2, 3, 4, 0, 0}, {0, 0, 0, 4, 0}, {1, 0, 0, 0, 1}}

• Thank you so much! Commented Feb 22, 2021 at 18:47