Problem is executing user defined function in version 6.3

Hello everybody,
I have recently got a chance to update the igor version from 6 to 6.3. I found that the procedures used in version 6 compiles in 6.3. That is good. When I try to fit the experimental data with a user defined Function in version 6.3, I am getting error message saying that "The fitting function returned NaN for at least one X value.".

Interestingly, when I used same Function and same data in version 6, it works without any issue. Can anyone faced some such problem and/or has solution to it.
I thank you in advance for your help.
Regards,
Maniraj
Show us the code for the fitting function, and tell us the input range of the data you're fitting.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
I attempted to run your function but failed for at least two reasons:
1. Your function references a wave named avgAG140612 but you have not provided the wave.
2. You have not provided initial guesses.

I have attached my attempt. If you can morph it into something that can be executed by we then someone may be able to help. Providing a ready-made, simplified example is often the best way to get quick and correct help.
Maniraj.pxp
Thank you for your interest. I am using igor for longtime and sure that proper name and appropriate initial guess values are taken care, there is no doubt.
Without changing anything, if I switch back to version 6.0.4.0, I can execute the function and get the things done, have a look an attached file.
This problem is continuing for all my functions in version 6.3, but compiles without any error!
Pls Let me know whether you can execute the function and get the same results in version 6.3.
Regards
Maniraj
Maniraj_V6.0.pxp
I can run your fit command successfully in Igor Pro 6.00.

I get errors in 6.34.

When I run this in 6.34 with the Igor debugger enabled I see an error message that says "Index out of range for wave xscale". This is probably the underlying cause of the error. To understand what is happening:
1. Choose Windows->Help Windows->What's Changed Since 6.10.ihf
2. Choose Edit->Find and search for "rtGlobals=3" (without the quotes).
3. After reading about this change, click the link to rtGlobals and then click the link to "The rtGlobals Pragma" and read about rtGlobals=3.

If you are not familiar with the Igor debugger, execute this:
DisplayHelpTopic "The Debugger"

Even if I change "rtGlobals=3" to "rtGlobals=1" in the procedure window, I still get other errors when I run the curve fit command. I think this has something to do with the global variables (V_FitIterStart?) you are using in the fitting function not being set up right. The debugger should help you investigate.

Searching for V_FitIterStart I find the help topic "Special Variables for Curve Fitting" where it says that V_FitIterStart is obsolete. I'm not the expert on curve fitting but I suspect that you would be best served to rewrite the program using the "All-At-Once" technique pointed to by the "Special Variables for Curve Fitting" topic. To see the topic execute:
DisplayHelpTopic "Special Variables for Curve Fitting"

Quote:
Variable/G V_FitIterStart
Variable/G V_FitMaxIters=100
Variable/G V_FitTol=0.000001
Variable/G V_FitOptions=1

These should not be set inside the fit function. It probably won't cause real problems, but you may not get expected results the first time you try to do a fit in a new experiment file. Except for V_FitIterStart, these global variables are read only at the start of fitting. Setting them during a fit will have no effect on the running fit.

I tried running your fit function with Igor's symbolic debugger enabled, and Debug on Error turned on. As HRodstein says, it stops on an error "Index out of range". That is caused by the loops running one too many times due to lines like this one:

                        while (j<=ndata)
Because Igor uses zero-based indexing for waves, the test must be simply while (j<ndata)
There are three lines that must be changed to fix the function.
When I fixed all three, then I got an error on a NULL wave on the return statement at the end. That is because the wave reference for convYSave is not created if you don't execute the Make statement. So any time the Make statement is skipped (which is most invocations of the function) the reference is NULL. I fixed that one by adding a line:
    if( cp==0 )
        Make/O/D/N=(ndata*(nc+1)) convYSave
    endif
    WAVE convYSave

With these changes, the fit runs correctly and returns the same answer that I found in the history of your experiment file.

As HRodstein says, the technique of using V_FitIterStart is obsolete. The function should be replaced with an all-at-once fit function.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
I implemented all your comments and found working nicely.
I will change my function to all-at-once fit function.
I thank you very much for all your interest.