Fitting multiple peaks procedure

Hello,

I am attempting to write a procedure to fit multiple gaussians to numerous spectra. I haven't been able to do it so far, the error being "Singular matrix or other numeric error". If I try the same fit to a single spectrum with the fit multiple peaks package it works!!!
I have tried to use the multiple peaks result as the initial guess to a single fit and it still doesn' work. This is the procedure I am attemting to run:

#pragma rtGlobals=1     // Use modern global access method.
#include  <Multi-peak fitting 1.4>

Function Gauss3(w,x) : FitFunc
    Wave w
    Variable x

    //CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
    //CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
    //CurveFitDialog/ Equation:
    //CurveFitDialog/ f(x) = y0+A1*exp(((x-X1)/B1)^2)+A2exp(((x-X2)/B2)^2)+A3*exp(((x-X3)/B3)^2)
    //CurveFitDialog/ End of Equation
    //CurveFitDialog/ Independent Variables 1
    //CurveFitDialog/ x
    //CurveFitDialog/ Coefficients 7
    //CurveFitDialog/ w[0] = y0
    //CurveFitDialog/ w[1] = A1
    //CurveFitDialog/ w[2] = B1
    //CurveFitDialog/ w[3] = X1
    //CurveFitDialog/ w[4] = A2
    //CurveFitDialog/ w[5] = B2
    //CurveFitDialog/ w[6] = X2
    //CurveFitDialog/ w[7] = A3
    //CurveFitDialog/ w[8] = B3
    //CurveFitDialog/ w[9] = X3

    return w[0]+w[1]*exp(((x-w[3])/w[2])^2)+w[4]*exp(((x-w[6])/w[5])^2)+w[7]*exp(((x-w[9])/w[8])^2)

End

Function Run()

make/O/N = (10) coef

coef={25147,4683.1,144.85,40.332,983.84,261.7,59.678,1258.7,77.517,130.99}

FuncFit Gauss3 coef test /X = Xwave


End


Thank you for any inputs.

Luiz
I am afraid it has to do with the way I am loading the data. For some reason if I try to do a regular gaussian fit (with the curve fitting tool) my data does not appear. And if I look at a table from the data the columns names appear with a [][0] next to it, even though each wave has only one dimension.
In case it helps, I attached one experiment with examples;
Thanks,
Luiz
Trial_Fit.pxp (240.6 KB)
hi!

There is something missing in the pxp file: FileImport.ipf
In any case:
ltizei wrote:
And if I look at a table from the data the columns names appear with a [][0] next to it, even though each wave has only one dimension.


I think you are using the /M flag of LoadWave, that's why Igor creates 2D waves (matrices) even if your data is 1D. But the FileImport.ipf file would help debugging ...

gregor
You are right. That has helped. Thanks. I am still trying the fit now. But at least I dont get errors
Thanks!!!
Ok. It finally worked. In the end I had two problems, the wrong input form and I was calling a global wave in a function in the wrong way. In the end, using the the parameters from the Multiple peak package worked.
Thanks!!!