08-02-2012 02:11 PM
Hello everybody! I am trying to set of data to a Lorentz curve to calculate a Q value (resonance.) I found a program on a thread from this forum that appears to work with the sample data set from the thread. However, when I try to run the program using my data set with known fitted coefficients as the initial guesses, we get an error in the Lev-Mar sub-VI -- something like “the input matrix is singular”. There’s a screenshot of my data in in the attached zip folder, as well as the text file containing my data.
My data curves down (reaching a minimum) instead of up, as in the sample data set, but it seems like that should be accounted for by the different initial guesses. I am thinking that something else is going on; hopefully it is something simple that I am just missing. Any help y'all can provide would be greatly appreciated!
Thank you!
08-02-2012 02:42 PM
Doctor G,
Where is the peak you are trying to fit? Your data set has a few squiggles which might be interpretted as resonances, but nothing is obvious as the "main" peak.
If you look at the subset from time = 0.00303 to 0.00316, you might have a peak you could fit. Perhaps some others as well. Have you tried fitting s subset around a suspect or known peak rather than the entire data set?
Lynn
08-02-2012 05:10 PM
Hello Lynn,
Yes, there are quite a few potential peaks in that data set. The peak you identified was the one that we are trying to fit (The peak should be trimmed by the cursors.) We used origin to fit that same peak in order to get the initial guesses for the coefficients in the screenshot. When it runs, we get the error message: "Error -20041 occured at NI_Gmath.lvlib: Nonlinear Curve Fit LM.vi:2 Possible reason(s): Analysis: The system of equations cannot be solved because the input matrix is singular."
Thanks!
-Garrison
08-02-2012 07:40 PM
Garrison,
Is your function correct? When I plot f(x,a) from LorentzianMOD.vi with that subset of data and your initial coefficients (or any of the coefficient sets generated by Lev-Mar) I never see any kind of peak. I see nearly straight lines or smooth curves without any hint of a peak. I do not know what the function should be, but I suspect that something is not right there.
Also, consider normalizing the data. It is possible that some strange numerical effects may be making convergence difficult.
Lynn
08-02-2012 08:08 PM
Hello Lynn,
I am not sure if the function is correct; however, it does appear to work correctly when using the example data from the other thread ("hisdata.txt" in the zip file.) How did you plot the function? I am not very familiar with how that works.
Normalizing the data sounds like a good idea, but looking at the other data, it appears as though there was an offset of ~1800. I'll still give it a try though.
Thanks for your help,
-Garrison
08-02-2012 08:22 PM
Garrison,
Plotting is easy. I just dropped a Waveform graph on the front panel of LorentzianMOD.vi and wired it to the same place as f(x,a).
Your data appears to have a mean value of about 0.025 as opposed to the 1800 in the other data. Even with an initial offset of 0.03, I still get no peak from your data.
What is the formula you intended to implement? Sometimes a second set of eyes will spot something that you missed because you were too close to it.
Lynn