If we want to get serious about fitting functions to our data, we can turn to gnuplot's sophisticated** fit** command.

You need the same datafile used in the previous recipe,` rs.dat`

. The following figure shows the same noisy sine wave, but this time the overlaid curve seems to be perfectly smooth:

The following script will produce the previous figure:

`f(x) = a*sin(b*x)`**
fit f(x) 'rs.dat' via a, b**
plot 'rs.dat' with lines lw 0.5 notitle, f(x) lw 4 title "Fit by gnuplot"

gnuplot's` fit`

command takes a function defined by the user containing several parameters and attempts to find the set ...

Start Free Trial

No credit card required