0

I want to extract coefficients of a linear formula and I wrote the following function. But it didn't work.

f = Subscript[x, 1] + Times[2, Subscript[x, 2]]
extractCoeff[f_] := Table[If[Head[f[[i]]] == Times, f[[i, 1]], 1], {i, Length[f]}]

What should I do?
Please tell me.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
tchappy ha
  • 463
  • 2
  • 7

0 Answers0