# How to get mathematical model from a data set with MATLAB

I have some values imported from excel about the annual sell of a product, with 3 var:

month, price, sold items

I have seen how to plot a chart using curve fitting tool but I need to define a math expression that can describe the relation between these variables.

How can I do this in matlab? Is there any tool that can achieve this automatically. If you look at the chart should exist a way to use an approximation that can mime the behavior(maybe with spline functions or n-point-hermit), is enough one approximated expression of the model that for the 3 var replicates a similar graph if plotted.

• Do you have any intuition as to what kind of function you want to model the data with or any indication as to what might make a good candidate function to model the data based on visual inspection?
– Paul
Dec 8 '15 at 15:41
• @Paul no I haven't such intuition for this reason I'm looking for a way to compute it. Dec 8 '15 at 16:13
• You might want to plot the data to see any trends. Dec 10 '15 at 18:12
• Generalized linear models are the best starting point for fitting models to such data. You have to convert the categorical "month" variable into a numerical value and then do the fitting. R has several built-in functions that do the job surprisingly well. Dec 10 '15 at 20:58
• I have yet plotted a fitting 3D graph with matlab, I need a way to generate also an expression in function of these var. with the standard fitting that I know I have obtained only a polynomial interpolation expression that isn't in function of the 3 variables Dec 10 '15 at 21:18