Am 14.03.2013 18:34, schrieb Thomas Grant:
> First, I would like to fit all the data files to a function:
>
> f1(x)=m1*x+b1
> f2(x)=m2*x+b2
> etc...
>
> then I'd like to fit them:
>
> fit f1(x) 'datafile_1.dat' via m1,b1
> etc....
>
> then I'd like to plot the data files, which I can do with a for loop:
>
> plot for [i=1:8] 'datafile_'.i.'.dat'
I悲 say you define all your variables m1,m2,b1,b2, ...., and then fit
them on
m1=1;m2=1;m3=1;b1=1;b2=1;b3=1
f(x,i) = value("m".i) * x + value("b".i)
fname(i) = "datafilenr".i.".dat"
do for [i=1:3] {
fit f(x,i) fname(i) via value("m".i), value("b".i)
}
plot for [i=1:3] fname(i), f(x,i)
OK, i tried this myself, and it works for the plotting, but the "value"
statement is not evaluated correctly in "fit".
This might be a bug in gnuplot.
Best regards, Karl