Suppose I have a vector space $V$, with $\{\vec e_1, \ldots, \vec e_n\}$ forming a basis of $V$. Also, suppose that I have a vector $\vec x \in V$, which I want to express as the unique linear combination of $\vec e_1, \ldots, \vec e_n$, e.g. $$\vec x= a_1 \vec e_1 + \cdots + a_n \vec e_n $$
Is there any MATLAB code, so I can get the coefficients $a_1, \ldots, a_n$?
(sorry, I didn't mean to restate the top comment as an answer, I just typed way too slowly )
Finding the coefficients $c_1 ... c_n$ for a vector $\vec{x}$ given basis $\{ \vec{b_1} ... \vec{b_n} \}$ amounts to solving
$ \left[ \begin{array}{ccc} \vec{b_1} & ... & \vec{b_n} \end{array} \right] $ $ \left[ \begin{array}{c} c_1 \\ ... \\ c_n \end{array} \right] = $$ \left[ \begin{array}{c} x_1 \\ ... \\ x_n \end{array} \right] $
So you should be able to solve this in MATLAB with the standard solve operator:
Where B is the matrix composed of your basis vectors and X is your $\vec{x}$ (all as column vectors).