I have a gnuplot code which includes a function fitting routine.
This routine is slow when a large number of data points must be fitted. The number of data points in my input file is variable depending on the parameters of some simulations I am running.
I wish to fit only 100 points. Up until now I have been doing this by manually computing the number of entries in my input file and dividing by 100 and using the resulting number as the "every N" command to the fitting command.
The fitting command I am using is:
fit f(x) "output.csv" every N using 1:4:9 via a,b
Where N = integer_round_down(output_file_length / 100.0) - I calculate this manually on a calculator before replacing the value of N manually in my gnuplot script. (Okay, so dividing by 100, I do that in my head, not on a calculator.)
Is there any way that I can get the number of entries in any of the columns, eg col 1, col 4 or col 9... Then use variables in my script to calculate N without having to edit my script everytime I change my simulation parameters?