|
From: Juergen W. <wie...@fr...> - 2007-10-22 11:51:45
|
> AFAIK calculating or approximating the 1st order derivative of a > function or x-y dataset was not (easily?) possible a few years ago from > within gnuplot, but maybe this has changed since then -- I don't follow > closely gnuplot's development anymore. > > My problem is the following: from a dataset, I first plot the x-y > values, then either fit a function to them or make a smoothing with > acsplines. So far, no problem. But afterwards, I need the 1st order > derivative of the fitted or smoothed curve. This would be easy if > gnuplot had a way to access data not only from the _actual_ row but also > from the following one in order to calculate Delta y / Delta x = y(row > +1)-y(row)/(x(row+1)-x(row)). This was not possible earlier. Has the > situation changed since then? If not, is it still possible to perform > differentiation from within gnuplot (even if this means using some awk > script or similar), as I would like to automate the process and gnuplot > is easily driven from a shell script or batch file. Well, AFAICS it has become possible in 4.3, though not very easily accessible. There is a new assignment operator (and a comma operator), so you can plot something like: old_x = NaN plot 'test.dat' using 1:(dx=$1-old_x,old_x=$1,dx) This only works with data file plotting. You can use the '+' pseudo file for fitted data (though I would recommend the analytic derivative in this case). For smoothed curves, plot the results into a table file (help set table) and use this file as given above. -- Completely untested -- Juergen |