LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 20041 with Nonlinear Fitting

Solved!
Go to solution

Hi,

I am trying to fit some data using a Python code and the nonlinear fitting function, but it is returning Error 20041, stating that the matrix is singular. Can anyone help me identify the problem with what I've put together? I'm using values in the hundreds for my initial guess, which is temporarily and unhelpfully labelled as "Array".

The data comes from the "Wavelength," "Reflection," "Light ref," and "dark ref" files and should be imported in that order. I'll also attach the Python code and a screenshot of the exact error. The Separated Fitting VI takes in the data and does the fitting.

 

This error seems to keep popping up in several different nonlinear fitting attempts I've made.

0 Kudos
Message 1 of 3
(721 Views)

You are just digging yourself a bigger hole (after this attempt).

 

  • Your x and y data differ in size.
  • Your parameter guess is still an empty array (why not enter a reasonable value and make it the default? What not give it a reasonable label? "array" is NOT reasonable)
  • There is no reason to burn all CPU with a greedy loop repeating the same fit millions of times per second.
  • Sorry, I don't do python, but your module path is empty.
  • You did not include your python code.

I recommend to start with some very basic tutorials. I doubt you need python for the model.

 

0 Kudos
Message 2 of 3
(685 Views)
Solution
Accepted by topic author adv11

Thank you for pointing out that my X and Y were different sizes.  Accessing Python was actually a better tool for me because I wrote the Python model before I even started with LabVIEW and the equation is huge, so I wasn't really digging myself a deeper hole.

The fix was very simple. Since the Python node requires the type of output expected to be wired to the "return type" input, I wrongly assumed that all other inputs wired needed to be the same type and was wiring the whole "a" array. I tried just indexing the array and wiring the first value as my "a" input instead, and it took it. No more singular matrix error.

0 Kudos
Message 3 of 3
(660 Views)