An issue in Global fit 2.ipf

Considering the error message " While executing a wave read, the following error occurred: index out of range for wave "MasterCoef". " when using NewGlbFitFuncAlAtOnce.

I have 4 sets of data to fit together. The first three sets are fitted with Func. 1 (N1 parameters) and the fourth set is fitted with Func. 2 (N2 parameters). N1 > N2. I want to call the function Func1 before calling the function Func2. In the "Global fits 2", it creates a wave "ScartchCoefs" to store the fitting parameters for each dataset. This wave has the fixed data points (here, N1) determined during initialization. However the wave "MasterCoef" has only (3*N1 + N2) points. Igor Pro gives the aforementioned warning messages when assigning the fitting parameters for the fourth set of data.

One solution is to make "ScartchCoefs" waves for each functions so that it can has the same number of data points as the number of the fitting parameters of the called fitting function.
update code for Function NewGlblFitFuncAllAtOnce(inpw, inyw, inxw)

Function NewGlblFitFuncAllAtOnce(inpw, inyw, inxw)
    Wave inpw, inyw, inxw
   
    Wave DataSetPointer = root:Packages:NewGlobalFit:DataSetPointer
   
    Wave CoefDataSetLinkage = root:Packages:NewGlobalFit:CoefDataSetLinkage

    Wave/T FitFuncList = root:Packages:NewGlobalFit:FitFuncList
   
    Variable CoefDataSetLinkageIndex, i
   
    Variable numSets = DimSize(CoefDataSetLinkage, 0)
   
    for (i = 0; i < NumSets; i += 1)
        Variable firstP = CoefDataSetLinkage[i][FirstPointCol]
        Variable lastP = CoefDataSetLinkage[i][LastPointCol]
        variable  npara=CoefDataSetLinkage[i][NumFuncCoefsCol]
        Make/O/D/N=(npara) root:Packages:NewGlobalFit:ScratchCoefs
        Wave SC=root:Packages:NewGlobalFit:ScratchCoefs
       
        CoefDataSetLinkageIndex = DataSetPointer[firstP]
        FUNCREF GFFitAllAtOnceTemplate theFitFunc = $(FitFuncList[CoefDataSetLinkage[CoefDataSetLinkageIndex][FuncPointerCol]])

        SC = inpw[CoefDataSetLinkage[CoefDataSetLinkageIndex][FirstCoefCol+p]]
   
        Duplicate/O/R=[firstP,lastP] inxw, TempXW, TempYW
        TempXW = inxw[p+firstP]
        SC = inpw[CoefDataSetLinkage[i][p+FirstCoefCol]]
        theFitFunc(SC, TempYW, TempXW)
        inyw[firstP, lastP] = TempYW[p-firstP]
    endfor
end
Hi Yaohualiu,
I discovered this bug a couple of months ago. I think John Weeks has changed the Global Fit 2.ipf code for future IGOR releases.
andyfaff wrote:
Hi Yaohualiu,
I discovered this bug a couple of months ago. I think John Weeks has changed the Global Fit 2.ipf code for future IGOR releases.

And if you send a request to support@wavemetrics.com, I can send you a copy of the latest bug-fixed version of Global Fit 2.ipf.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com