01-26-2018 05:02 AM
Hi
I have (again) questions regarding the nonlinear LM fit. I took the vi gracefully posted by altenbach here :
I would like to fit a baseline + few gaussians to experimental data. I modified a little bit the previous exemple, see attached file, but I am getting an error. Any help ?
Thanks
Solved! Go to Solution.
01-27-2018 04:38 AM
Hi
I am trying to fit a sum of a few Gaussians (3-4 depending on the input data) and a straight line. The positions and amplitudes are known so I want to fit only the widths.
I am using LM fit with formula and wrote something to write the formula depending on the number of gaussians. The whole program take some X,Y data then find peak amplitude, and positions then I pass a 2D array with 3 columns : amplitudes, positions and estimated widths. However I get an error when parsing this formula. any ideas ?
see attached file with typical data
thanks
01-27-2018 11:57 AM - edited 01-27-2018 12:07 PM
@nitad54448 wrote:
I would like to fit a baseline + few gaussians to experimental data. I modified a little bit the previous exemple, see attached file, but I am getting an error. Any help ?
I have no idea why you are wiring the "weight" input with the Y data. Disconnect that and the fit will have no error.
(Also, why are you using the bounded version with empty arrays as bounds? Just use the plain version).
01-27-2018 12:07 PM
@nitad54448 wrote:
I am using LM fit with formula and wrote something
You really should use the VI model, much higher performance and easier to maintain.
Still your obvious mistake is that you have 5 parameters, but the parameter guess array only contains three elements. These sizes must match.
01-27-2018 12:34 PM
Hi again
I think I post an old version, I did not see the 3 parameters (silly mistake), anyway with 5 parameters in the array I get again an error. Pls check the file.
Thanks for looking
N
01-27-2018 12:42 PM
Hi again
Two blunders in one day : I need to take a holiday. Indeed I removed the weight and then there is no error. However, as you can check in the vi that I posted there is no fit either. I mean the program just stops with the guess parameters.
thanks
01-27-2018 12:57 PM - edited 01-27-2018 01:25 PM
@nitad54448 wrote:
I think I post an old version, I did not see the 3 parameters (silly mistake), anyway with 5 parameters in the array I get again an error. Pls check the file.
The "initial parameters" input still only contains 3 elements. (The orange array wired to the top of the fitting VI)
Now you messed up the array with parameter names, which was correct before. So undo that! (Now it contains 8 parameter names, some in duplicate.)
01-27-2018 01:16 PM - edited 01-27-2018 01:18 PM
Hi
OH, got it.
In the 2D table at left I put all parameters for Gaussians (took your model, just add lines for more gaussians). Now I take the width column 1D array, I put a0 and a1 and the guess parameters are in an array of 5. I got 5 unknowns a0 to a4 in my formula.
Still get an error (version corrected_2)
Can you see something else in error?
01-27-2018 01:18 PM
OK, here's what I modified. Your 2D paramter arrays contains some extra data. It is slow, but works without error.
01-27-2018 01:22 PM
@nitad54448 wrote:
Can you see something else in error?
See my code above. Your "Tableau" has too many and duplicate elements (resize the indicator to see all).