What's wrong is that your fitting problem is in bad shape, and reading the documentation about the fit command, particularly "help fit tips", would have told you what's bad about it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
# inline data
$data << EOD
5.19e+14 7.91e-14
5.49e+14 8.56e-14
6.88e+14 1.67e-13
7.40e+14 1.96e-13
8.21e+14 2.40e-13
EOD
f(x) = a*x + b
# best option: do not use a non-linear fitting tool for a linear fit,
# use 'stats' instead:
stats $data using 1:2
a = STATS_slope
b = STATS_intercept
# or, if you insist on 'fit':
# Do set start-up values! The order of magnitude is important.
# Otherwise gnuplot will assume start-up values of 1, which is way off.
a = 1e-28
b = -1e-13
fit f(x) $data using 1:2 via a,b
set key bottom
set format y "%h"
plot \
$data t "measured", \
STATS_slope*x + STATS_intercept t "stats result", \
f(x) t "fit result"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey!
I'm trying to fit a function in the form of
f(x)=a*x+b
to these measurements:However, after
fit f(x) measured.csv using 1:2 via a,b
, gnuplot returns..., which is a line thats rising far, far to fast.
Any idea what's wrong?
Thanks in advance!
What's wrong is that your fitting problem is in bad shape, and reading the documentation about the fit command, particularly "help fit tips", would have told you what's bad about it.