# Fit exponentially decreasing oscillation [closed]

It is a simple fit I would like mathematica to do: Fitting a set of experimentally obtained data points with an exponentially decreasing cosine function.

 datafit = Table[data3[[i, 2]], {i, 1, Length[data3]}];
tab = Table[Sin[i], {i, 0.01, 100, 0.01}];
model = Cos[a*x] Exp[b*x];
fit = FindFit[datafit, model, {{a, 100}, {b, -10}}, x]

Show[ListLinePlot[data3, PlotStyle -> Red],
Plot[{Evaluate[model /. fit]}, {x, 0, 0.6}]


This should give me the fit, but instead completely wrong values are found for the parameters, even when I adjusted the starting values.

The file can be found here (Dropbox).

OutPut:

With the blue "Fit" and the data in red.

I hope somebody finds my mistake or can explain why Mathematica is doing this!

EDIT: For a=145 and b=-2.8 I get the following result:

Which shows, that at least the initial values I have chosen are somewhat resonable.

• Your dropbox file doesn't load for me. However, odds are you just have to specify initial values. Commented Nov 24, 2016 at 10:01
• First plot the model with your starting values against the data and make sure that you've got at least the frequency approximately correct. Commented Nov 24, 2016 at 10:14
• @Feyre thanks for your comment, I did specify the initial values (added a picture), but somehow Mathematica does not find the best values obviously. The file is a .dat-file, which is the reason that is not available for a priview in your browser, but can be imported to Matematica. Use this Link: (dropbox.com/s/xufd736fburdq8a/norm.dat?dl=0) Commented Nov 24, 2016 at 10:32
• You're plotting data3, but you're fitting against datafit, which doesn't have the x values. If you fit the same dataset that you're plotting, and you make sure the frequency starting value is chosen correctly, it will work. Commented Nov 24, 2016 at 10:59
• The frequency starting value needs to be quite close, by the nature of fitting against an oscillating function. Just today there was another question about that: mathematica.stackexchange.com/questions/131933/… Commented Nov 24, 2016 at 11:05

FindFit does an excellent job without any starting values, at least in Mathematica 11
file = FileNames["norm.dat", NotebookDirectory[]];