This is similar to this question and this but my problem is that I have several hundred files that need to be simultaneously fitted and plotted on one graph. Unlike the other questions posted I'm looking for the best fits for each file, not for the global data set so cat won't work.
I was hoping to use fit.. for like I do for plot but it's not working so well. Here's what I've got so far:
f(x) = 1+d*exp(-(x-f)**2/(2*(g**2)))+a*exp((-(x-b)**2)/(2*(c**2)))
filename(n) = sprintf("rheosaxs_saxs_%005d_0001_var_rebin_div.dat", n)
fit f(x) for [n=575:584] filename(n) u 1:2 via a,b,c,d,f,g
plot for [n=575:584] filename(n) using 1:2, f(x)
the error I get is: line 60: undefined variable: for
which corresponds to the fit f(x) for [n=a:b]
I know that my starting parameters are reasonable because I can plot them without the fit command and they look sensible. Similarly my plot for works ok.
Any ideas? Thank you :)

fit ... forwould work, you would always overwrite the estimated fit parameters of the previous iteration. I posted a possible solution for such a szenario in stackoverflow.com/a/20323981/2604213, not sure if now there is a better approach using array, which were introduced with version 5.2.foris defined differently in gnuplot to the standard definitiondo for [i = 1:10] { fit ... via a; array[i] = a; }I'll see later at home, if that could work.