03-09-2015 03:43 PM - edited 03-09-2015 03:52 PM
Hi everybody,
I am trying to fit a custom nonlinear curve to my data. I want to fit a curve to the data twice. After the first fit, I want to use the coefficient a (6.57962) in my second curve fit as my coefficient b. When I try to use this and create a custom equation by string concetanete, everything seems fine but I do not get what I expect to get. To double check I used curve fitting express VI and I added 6.57962 as a coefficient in my equation and at the end a turns to be 6.752. However, this does not happen in my second curve fit. Does anybody have any idea what might be wrong? I cannot find my mistake, could you please help me?
Thank you very much
03-09-2015 07:25 PM
The errors you get provide some clues, although they are not very explicit.
The -23001: Syntax error of parser is usually a sign that your string describing the function is ill-formed or that there is a parameter mismatch. You have both.
The string array constant feeding into the second Lev-Mar VI has two elements, the second one being an empty string. Even though the string is empty, the parser expects two elements in the Initial Parameters array. But since your equation has only one parameter (a), the proper solution is to remove the blank element from the constant array.
The other problem is that the first Initial Parameters array is empty. Maybe you always enter two values but I did not know what to put in.
The second fit is somewhat sensitive to the initial Parameter value. Negative values do not work. 1 returns 6.753... 2 through 6 and 8 (integer values only) return 6.246... 7 returns the same result as 1. Values 10 and above return the value entere with error -20041 (singular matrix) appearing at >=12.
The initial b parameter in the first fit does not matter over a fairly wide range.
I also noticed that you seem to have a severe allergy to straight wires. Wires running all over the diagram and particularly behind other objects makes it very hard to read your code. Dataflow along the wires should generally be from left to right as much as possible. The code works the same regardless of the number of bends in the wires but straighter wires are much easier on the programmer.
Lynn