Polyfit and polyval are two MatLab functions that I use almost all the time. They make my task super-easy. This video shows how we can use these two functions to make our life easier. Although this video shows only first-order curve fitting, you can use polyfit to fit whatever order you like just change the third argument. 2 for a quadratic data fit, 3 for cubic and you understand the rest.