opisthofulax
opisthofulax

Reputation: 551

Troubles fitting exponential with gnuplot

I have a file called 'dataset.txt' with inside these data

#Temperature (K) - Pressure (kPa)

310.2 5.349
315.6 6.682
320.2 8.015
325.2 10.681
330.2 14.680
335.2 17.346
340.2 22.678
345.2 28.010
350.2 34.675
355.2 44.006
360.2 52.004
365.2 62.668
370.2 73.332

I have to fit the curve given by data with an exponential of the form

f(x) = a * exp(x * b) + c

So i digit

f(x) = a*exp(x*b) + c
fit f(x) 'dataset.txt' u 1:2 via a, b, c

but I get an error of the type

Current data point
=========================
#               = 1 out of 13
x               = nan            
z               = 5.349          

Current set of parameters
=========================
a               = nan            
b               = nan            
c               = 1              

     Function evaluation yields NaN ("not a number")

Can anyone explain me why? Is there a syntax error? I have already fitted this curve with Origin (on Windows) and no problems occurred. Why does gnuplot give me this strange error? Thx!

Upvotes: 1

Views: 1433

Answers (1)

maij
maij

Reputation: 4218

This is a floating point number problem.

You do not initialise the fit parameters, so gnuplot chooses default values a=b=c=1. Evaluating the exponential function exp(x*b) now results in huge values, which leads to (floating point) Infinity and NaN in the Marquardt-Levenberg fitting algorithm.

Try to initialise the fit parameters, especially b, for example b=0.001.

Upvotes: 3

Related Questions