Based on a variant of the frequency function approach of Almgren, we establish an optimal bound on the vanishing order of solutions to stationary Schr¨odinger equations associated to a class of subelliptic equations with variable coefficients whose model is the so-called Baouendi-Grushin operator. Such bound provides a quantitative form of strong unique continuation that can be thought of as an analogue of the recent results of Bakri and Zhu for the standard Laplacian.