The purpose of this paper is to suggest a numerical technique to solve fractional variational problems (FVPs). These problems are based on Caputo fractional derivatives. Rayleigh–Ritz method is used in this technique. First we approximate the objective function by the trapezoidal rule. Then, the unknown function is expanded in terms of the Bernstein polynomials. By this method, a system of algebraic equations is driven.We provide examples to show the effectiveness of this technique, which is considered in the current study.