live plot view of multipeak fit with integrated background

Dear All,

After very long time, I am trying with most recent version of the Igor for peak fitting, I see there are lot of packages available, but for multiple reasons I like to have a code for my purpose.

It is a typical spectroscopy data, where more gaussian type peaks are present on top of integrated background. 

I got first hand success with below code (which is very simple I suppose):

Function fittryOriginal(w,x) : FitFunc
    Wave w
    Variable x
    return w[0]*exp(-((x-w[1])/w[2])^2) +     w[3]*exp(-((x-w[4])/w[5])^2)+     w[6]*exp(-((x-w[7])/w[8])^2)+    w[9]*exp(-((x-w[10])/w[11])^2)+  w[12]+x*w[13]+x*x*w[14]    
End

Here, are there any way to get each gauss as independent wave that  can be plotted and observed on the fly, like g1, g2 etc ?
If I want to use integrated background, instead of poly, I need to import the original raw data and do the calculation over interval, but should I do it inside loop? background code is like below

 

// Backward loop for background calculation
    for (m = ndata - 2; m >= 0; m -= 1)  // Start from second last point and go to the first
        bg[m] = bg[m + 1] + w[3] * srcData[m + 1] * dx
    endfor


Due to very long gap, I nearly got lost coding. Any help can help a lot.

 

I am not sure I understand you fully, but I assume you want to fit multiple Gaussian functions and a polynomial background, while observing the individual components on the fly. This is exactly what the Multipeak Fit package is for (hence the name). Go to Analysis => Packages => Multipeak Fitting to start the package. There is also a demo where you can learn the basics of this tool: Go to File => Example Experiments => Curve Fitting => Multipeak Fit Demo to load the demo experiment.