I have data files "y.csv" which contains several runs (data sets) of an experiment in columns that I want to simultaneously fit to a single function. It should work like plot for [i=2:*] "y.csv" using 1:i
to automatically accomodate however many columns are in the file. Here is a short example data file:-
,B,C,D,E,F,G,H
01,,,,,,,
02,0.2200,0.2200,0.2080,0.2170,0.1530,,
03,0.2720,0.3230,0.2530,0.2380,0.2620,,
04,0.3900,0.3790,0.3770,0.3760,0.3500,,
05,0.5520,0.5600,0.5450,0.4830,0.4870,,
06,0.6640,0.6300,0.6830,0.6030,0.6520,,
07,0.6440,0.6900,0.6360,0.5960,0.6520,,
08,0.6030,0.6470,0.6190,0.6300,0.6280,,
09,0.5450,0.5890,0.5860,0.6830,0.5540,,
10,0.6370,0.6430,0.5800,0.5270,0.6180,,
11,0.6400,0.5600,0.7190,0.6780,0.7420,,
12,,,,,,,
I can automatically plot each of these columns, overlooking column headers, etc with:-
set datafile separator ","
set datafile columnheaders
set key autotitle columnheader
set key top left
set key title "Run"
set xrange [1:12]
set xlabel "Dilution (Proportional to log([]) )"
set ylabel "Response"
plot for [i=2:*] "y.csv" using 1:i with linespoints
I can set up a function to fit with the following:-
sig(x) = 1 / (1+exp(-x)) ; # Appears stable enough in gnuplot
A = 0.6 ; # Sigmoid Amplitude
B = 0.2 ; # Sigmoid offset
C = 6 ; # Center shift on displayed X axis
K = 1 ; # Shape factor
ssig(x) = B + A*sig(K*(x-C)) ; # Fit to this
And, I can fit to the first data column with:-
fit ssig(x) "y.csv" using 1:2 via A,B,C,K
But I can't work out the syntax of how to automatically do this over all the columns like I can for plotting. I was expecting something like
fit [1:-1:i=2:*] ssig(x) "y.csv" using 1:i via A,B,C,K
would iterate over the columns. I just don't understand the multi-branch syntax, and guess I am missing some simple concept. Many thanks


A_1, B_1, C_1, K_1for the first set,A_2, B_2, C_2, K_2for the second and so on? Or do you want to perform a multi-branch fit, where some of the fit parameters are the same for all data sets (e.g.AandKmight have some global meaning), while others have individual values for each data set (e.g.B_1, B_2, B_3...)? - EldradA, B, C, Kto best fit all the runs of the experiment, to the function. - mjpmulti-branch fitin a wrong way. It would mean that you have two (or more) functions, that share some (but not all!) common parameters. For example you might fitf_1(x) = B_1 + A*sig(K*(x-C_1))to the first data set,f_2(x) = B_2 + A*sig(K*(x-C_2))to the second one and so on. (Note that the functions depend on the sameAandK, but differentB's andC's!) But according to your comment you just want to use all data points for one single function – I provided an answer for that. - Eldrad