Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I have a vector like this:

V = {a*exp1+b*exp2+c*exp3, a*exp4+b*exp5+c*exp6, a*exp7+b*exp8+c*exp9}

and I want to get :

mat = {{exp1, exp2, exp3}, {exp4, exp5, exp6}, {exp7, exp8, exp9}}

from vector

var = {a, b, c}

so : mat.var === V

share|improve this question

marked as duplicate by Mr.Wizard Aug 1 at 17:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 1 down vote accepted

Use Coefficient:

var = {a, b, c}
V = {a*exp1+b*exp2+c*exp3, a*exp4+b*exp5+c*exp6, a*exp7+b*exp8+c*exp9}    
Transpose[Map[Coefficient[V, #] &, var]]
{{exp1, exp2, exp3}, {exp4, exp5, exp6}, {exp7, exp8, exp9}}
share|improve this answer
    
Thats the solution Thanks! In case of Vector is in form: V = {{a*exp1+b*exp2+c*exp3}, {a*exp4+b*exp5+c*exp6}, {a*exp7+b*exp8+c*exp9}} Use Reshape[list_, dimensions_] := First[Fold[Partition[#1, #2] &, Flatten[list], Reverse[dimensions]]]; Reshape[Transpose[Map[Coefficient[V, #] &, var]],{3,3}] –  DdS Aug 1 at 19:28

You want CoefficientArrays:

CoefficientArrays[V, var] // Last // Normal
{{exp1, exp2, exp3}, {exp4, exp5, exp6}, {exp7, exp8, exp9}}
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.