How to access a wave inside a fit function FitFunc

Dear all,
I am trying to fit a function I wrote myself. The function depends on itself so I need to access the wave I want to fit to get the result.
Let say I have a set of data, Y versus X, and I need to fit a function fx. Within this function I would need to access Y because the function depends on "itself".
Thank you in advance.
F
This is a somewhat confusing request.

It kind of sounds like you're trying to fit something like a differential equation or a recursive series, where each Y point in your MODEL depends on one or more previously MODELED Y points, in addition to potentially depending on the X value. I.E.

y_n = f(x_n, y_(n-1), coefs)

If so, use an All-At-Once fit function:

DisplayHelpTopic "All-At-Once Fitting Functions"

Or are you saying you want to the fit to minimize the difference between
y_i and y(x_i, y_i; coefs)?

where the model at the ith point depends on the measured data at the ith point? That's kind of what "...I need to access the wave I want to fit to get the result" sounds like to me, but is much fishier from a statistical point of view. It sounds completely circular to be honest, but who knows with the level of detail you've supplied. If that is what you want to do it can be programmed. Call your data up from within the fit function using a wave reference to a global wave. Don't modify it and don't try to pass it in as a parameter (FuncFit creates it's own wave to hold the modeled values for comparison to the data, and it needs to pass it in through the y parameter). It still might be easier to use an all-at-once format so you know with data point you're on. The normal fit function format calculates one y value at a time per one x value, so you'd have to use the input x value to determine where to look in your y data.

I.E.

Function myfit(coefs,Yout,Xin)
wave coefs, Yout, Xin
wave Ydata = root:Ydata
Yout = SomeFunction(Ydata,Xin)

End

I have the same question as ikonen, but with a slightly different approach:

Do you have an implicit function? That is, one that can't be solved for Y? That would be like the standard equation for an elipse:

Y^2/A + X^2/B = 1

In that case read this help topic (copy the command, paste it into Igor's command line and press Enter):

DisplayHelpTopic "Fitting Implicit Functions"

Or perhaps you have a function, such as a numerical integration of a system of ODE's in which Yn depends on Yn-1. In that case you need an "all-at-once" function:

DisplayHelpTopic "All-At-Once Fitting Functions"


Either way, I'm sure you will have further questions :)

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com