From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-12-2012 09:39 AM
I am trying to use the (Constrained) Nonlinear Curve Fit VI to analyze a step response. Is it possible to define a parameter to fit a time shift? That way I won't have to be so careful about getting the precise starting point of the analysis window. E.g. y(t) = f(x(t-t0),a=[a0, at1]) or y(t) = f(x(t),a=[a0, a1, t0])? It requires an IF (case statement) inside the function. You can do this in Excel so I would have thought LabVIEW could do it, too. See attached simplified example of a time-delayed linear fit. It gives Error -20041 occurred at NI_Gmath.lvlib:Nonlinear Curve Fit LM.vi:1. Possible reason(s): Analysis: The system of equations cannot be solved because the input matrix is singular.
Regards,
Solved! Go to Solution.
10-22-2012 05:57 PM
Hi
Thank you for contacting National Instruments, my name is Andrea and I’ll be assisting you with your issue.
I am going to check the vi that you have attached.
Regards,
10-22-2012 06:45 PM
If you open the Nonlinear Curve Fit LM.vi and place some probes you find that the matrix fed to the Inverse Matrix.vi is:
1785 153 0
153 20 0
0 0 0
That matrix is produced by abx.vi. The LM function and gradient.vi calculates the values of your function and the gradient. The second column of the gradient is all 1s and the third column is all zeros.
Perhaps this is a case where explicitly calculating the f'(X,a) in linearShift.vi might be worth a try. Then you can assign suitable values at the discontinuity and avoid the singular matrix.
Lynn
10-22-2012 06:53 PM - edited 10-22-2012 07:23 PM
Your t0 paramter is quantized, thus the partial derivatives won't work (changing the parameter has no effect except for the few points where it jumps by one over an infinitesimal small increment).
You need to rewrite the formula so you get a smooth shift. Shouldn't be too hard.
10-22-2012 07:22 PM
10-23-2012 07:31 PM
Thanks altenbach. Your VI works. Actually, after using yours as a reference, all you have to do to my original linearShift.vi is replace the Y[i] = X[i-n].vi with the subtract VI, and it works! Not exactly sure why... Your additional style improvements are also appreciated.
10-24-2012 01:25 AM
Looking at the code again, you should also delete these two error local variables. You are writing to both error out terminals from different places with different information, so the final outcome is totally upredictable.