comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » CURVEFIT for multiple datasets
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
CURVEFIT for multiple datasets [message #58480] Thu, 31 January 2008 04:55
chloesharrocks is currently offline  chloesharrocks
Messages: 16
Registered: January 2008
Junior Member
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Ʃ
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Creating a dicom-file in HSV colors
Next Topic: Re: Vertical alignment of text with XYOUTS

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 06:27:45 PDT 2025

Total time taken to generate the page: 0.72192 seconds