# Linear Fit of multidimensional data

I am trying to find linear decomposition of vector B (of arbitrary dimension $n$) in the form :

$B = \alpha_{1} C_{1} + \alpha_{2} C_{2} + ...$

where $C_{i}$ are known vectors (of dimension $n$) and $\alpha_{i}$ are scalars (to be determined).

I am trying to do it using LinearFitModel, but I have trouble understanding how it works in my case from the Mathematica documentation. I tried :

X = Transpose[{C1,C2,C3,X}]
f = Transpose[{C1,C2,C3}]
t = Table[i,{i,1,Length[X]}]
LinearModelFit[X,f,t]


but I get the following error :

LinearModelFit::fitm: Unable to solve for the fit parameters; the design matrix is nonrectangular, non-numerical, or could not be inverted.


Has someone experience with this ?

• LinearSolve[] looks to be better for this. – J. M. will be back soon Aug 31 '15 at 9:42