Dear all
I'm trying to fit an exponential curve to multiple data sets which
have been overplotted on a graph. To get a feel for CURVEFIT (as I'm
a novice at IDL and CURVEFIT), I wrote the following 2 programs (based
on the one given in IDL help), which produce a nice exponential curve
when there's only ONE dataset:
=====
PRO gfunct, x, t_a, f_t, PDER
t_bx = EXP(t_a[1]*x)
f_t = t_a[0] * (t_bx) + t_a[2]
;If the procedure is called with four parameters, calculate the
partial derivatives
IF N_PARAMS() GE 4 THEN $
pder = [[t_bx], [t_a[0]*x*t_bx], [replicate(1.0, N_ELEMENTS(x))]]
END
=====
and
=====
PRO CURVE_FITTING
x=FLOAT(indgen(10))
y=[12.0, 11.0, 10.2, 9.4, 8.7, 8.1, 7.5, 6.9, 6.5, 6.1]
weights=1.0/y ;Define a vector of weights
A=[10.0, -0.1, 2.0] ;Provide an initial guess of the function's
parameters
yfit=CURVEFIT(x,y,weights, A, FUNCTION_NAME='gfunct') ;Compute the
parameters
print, 'Function parameters: ', A
loadcolors
pson, filename='Curve_fitting.ps'
plot, x, y, yrange=[5,13], ystyle=1, xrange=[0, 11], xstyle=1, psym=1,
color=0
oplot, x, yfit, linestyle=1, color=5
psoff
END
=====
How can I extend this for the case when I have say 2data sets, ie:
x=[[indgen(10)], [indgen(10)]]
y=[[12.0, 11.0, 10.2, 9.4, 8.7, 8.1, 7.5, 6.9, 6.5, 6.1], [11.5, 10.8,
10.3, 9.5, 8.6, 7.8, 7.5, 6.4, 6.4, 5.9]
and I want to plot an exponential curve through all of this data?
Eventually, I would like my program to be able to plot an exponential
curve through 2000+ data sets all of which have been plotted on the
same graph and seem to show an exponential trend.
Thanks very much
ChloƩ
|