Analytic solution of a class of fractional differential equations with variable coefficients by operatorial methods