LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Lev-Mar Error Message

Hi guys: I've got a long story here. It all started when I was using Lev-Mar VI to make a Nonlinear Lorentzian fit. This fit however gives me a very strange error message: "LabVIEW: An exception occured within the external code called by a Call Library Function Node. This might have corrupted LabVIEW's memory. Save any work to a new location and restart LabVIEW.VI "test.vi" was stopped at node 0x0 of subVI "NI_AALPro.lvlib:Real SVD Decomposition.vi". Then, when I run it again, it gives me another error message saying: "Error - 20041 occurred at NI_Gmath.lvlib:Nonlinear Curve Fit LM.vi" "Possible reason(s): Analysis: The system of equations cannot be solved because the input matrix is singular." I've attached my program and the data with this message. Can someone please help me out. Thank you very much
0 Kudos
Message 1 of 7
(6,643 Views)
Oh, there is one thing I forgot to mention that is the "Fit equation.vi" and "general lorentzian.vi" are adopted from someone who posted messages in this forum. They claim it works, so I just used it.
0 Kudos
Message 2 of 7
(6,631 Views)
I cannot open your zip archive, it seems corrupt. Can you try to attach it once more? (or maybe create a fresh one first).
0 Kudos
Message 3 of 7
(6,625 Views)
Sorry for the inconveniency. Here is the re-upload of the zip file.
0 Kudos
Message 4 of 7
(6,612 Views)
OK!
 
The main problem is the fact that you are calling the "general Lorentzian" function, which expects 5 parameters and extra data, yet your initial estimates only contain 4 elements and you don't provide the extra data. At the moment you should call the plain "Lorentzian". It works well!
 
The more general problem is the fact that you do many things way too complicated. Virtually all of your loops have near equivalent built-in functions.
The code is completely fragmented and parts linked via local variables, while sequences are then used to re-establish execution order. You should also get rid of all stacked sequences and all these extra controls that have the sole purpose of providing local variables.
 (You seem to be coming from text based programming languages, so you should loose that kind of sequential thinking! The wire is the variable! See also this old post)
 
Once everything is wired together, data dependency will properly determine execution order and the sequences are unnecessary.
 
I cleaned up the code a bit, but please verify correct operation (you might need to tweak some edge effects here or there, nothing a +1 or -1 cannot fix, who knows? I literally translated some code segments because I wasn't sure what you were really trying to do). One glaring error was the fact that you indexed into the array subset as if you are still operating on the full array. I left a diagram comment. I am sure many more simplifications are possible.
 
I reduced the entire project to 4 relatively simple VIs. The main VI also shows the best fit function, overlayed over the data. See for yourself.
 
Let me know if you have any questions. Good luck!
 
(Of course you should make the main program into a real UI, with buttons to read a new data file, automatic refitting if the initial estimates or cursor position changes, error handling, etc. Just add a while loop and an event structure, the rest should almost fall into place. :))
 
Quite a few of your code constructs would make the Rube Goldberg Hall of Fame, maybe I submit some so everybody can learn. :D)
 
 
 

Message Edited by altenbach on 08-11-2007 12:21 PM

Download All
0 Kudos
Message 5 of 7
(6,600 Views)
That was a big valuable lesson. Thank you so so much altenbach. 😄
0 Kudos
Message 6 of 7
(6,586 Views)

The good thing is that LabVIEW is easy once you get the hang of it! 😄

You should be able to get things going with the more complicated formula, something I have not tried. Let me know if you have any problems. Good luck!

0 Kudos
Message 7 of 7
(6,577 Views)