I want to fit data to a nonlinear function and wants to claculate some parameters, for that i need a subroutine whcih fits the data to a nonlinear function using least square method.
This procedure gives some detailed statistics of the fitting with errors. Which means if you get large errors in your parameter estimates, you can decide not to use them.
The code looks like below (modification of what is presented at https://gist.github.com/ltn100/397465):
# Define function (eg if fit is quadratic. Also works for other common functions)
f(x)=a*x**2+b*x+c
# Perform fit
fit f(x) "datafile" u 1:2 via a,b,c
# Wait for iterations to complete and give you values of a, b and c with errors in the computations. The results are stored in a file say fit.log after running this code in gnuplot..