Using object-oriented programming in MATLAB, a collection of functions, named Fourfun, has been created to allow quick and accurate approximations of periodic functions with Fourier expansions. To increase efficiency and reduce the number of computations of the Fourier transform, Fourfun automatically determines the number of nodes necessary for representations that are accurate to close to machine precision. Common MATLAB functions have been overloaded to keep the syntax of the Fourfun class as consistent as possible with the general MATLAB syntax. We show that the system can be used to efficiently solve several differential equations. Comparisons with Chebfun, a similar system based on Chebyshev polynomial approximations, are provided.