05-25-2009 02:22 AM
So I have to develop a non linear fitting program to fit our experimental data. At frist I wasn't sure which of the instances I should use: either the vi or the string one. I decided on the vi version after looking through the previous posts made on this forum. Given that I was unsure how to select the parameters, I had a look at the vi that has been discussed in this thread and used that as template of what I might need to do.
However I have run into a problem. I get the following error:
Error -20041 occurred at NI_Gmath.lvlib:Nonlinear Curve Fit LM.vi:5
Possible reason(s):
Analysis: The system of equations cannot be solved because the input matrix is singular.
I can't work out why I am getting this error in the curve fit vi. Also if I then continue with running the vi, the values in the best fit parameters now just match those in the initial fitting parameters. The parameters I have used are fairly close to the known numbers (ie the ones I used to calculate my 'data'), and they have been selected as the default values.
Any help on this would appreciated. I have attached 3 vi's. One is the fitting vi, another the fitting function and the third being a vi for the weight. The function I am trying to fit is given in the fitting function vi. The equation to calculate the weight is given in the weight vi. I should also note that the data I have attached is not from my actual experiment (hence my calling it fake data), but it is typical of the sort of data I will be getting. I have included header info in this data file as this is the style the data will come in, so to is location of the data columns (have only filled the relevant columns with data for the purposes of developing the fitting program).
I am using Labview 8.6.
Solved! Go to Solution.
05-25-2009 02:15 PM
hi
can you check that the determinant of the matrix is not zero ? maybe you have a typo in the data
N
05-25-2009 02:51 PM - edited 05-25-2009 02:54 PM
05-25-2009 04:38 PM - edited 05-25-2009 04:40 PM
I think your units are all messed up! 😮
You would get a great fit if you do the following two changes:

Here's an example fit with slightly off starting values (data -Fit is much less than one percent):

05-27-2009 07:17 PM
06-01-2009 04:08 AM
So I was trying to work out where I was missing that 4E-21 factor from. It works out that I don't need to work the value out from first principles, but rather I need to divide the result by kT (since the potential energy is in terms of kT). So, altenbach, your figure of 4E-21 was indeed pretty close to the mark! :)n Looking back it was so simple, but just didn't pick it u.
I still need to work on the weighting issue. Thanks for your help on this, it is much appreciated! 🙂
06-01-2009 04:30 AM
I do have another question though. Becuase I have to divide by kT now, i need to have a temperature value here. I would prefer to be able to input the temperature as needed (even though it is unlikely to change that much). Thus I want it to be an indicator. Since I am using this sub-vi (this is the fit function vi) in my fitting vi as a strictly typed vi and and am it referencing using the Call by Reference Node, I can't seem to access the temperature indicator (or wire it up so I can have the indicator in the main vi front panel).
Do you have any suggestions as to how I might be able to incorporate the temperature indicator in?
Thanks
06-01-2009 04:51 AM
06-01-2009 08:29 PM
Oops, I just realised I was saying an indicator when in reality I did mean a control.
Thanks altenbach, I will give that a go now.
06-01-2009 11:00 PM - edited 06-01-2009 11:01 PM