  In this paper, by use of matrix inversions, we establish a general
$q$-expansion formula of arbitrary formal power series $F(z)$ with respect to
the base $$\left\{z^n\frac{(az:q)_n}{(bz:q)_n}\bigg|n=0,1,2\cdots\right\}.$$
Some concrete expansion formulas and their applications to $q$-series
identities are presented, including Carlitz's $q$-expansion formula, a new
partial theta function identity and a coefficient identity of Ramanujan's
${}_1\psi_1$ summation formula as special cases.
