LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I edit nonlinear fitting routines?

I am measuring a circuit current using a two-phase lockin amplifier.  The circuit is driven by a known ac source voltage (amplitude and phase).  I have these two pieces of information--current and voltage---over a range of source frequencies which can then be used to determine the complex impedance Zm of the circuit as a function of frequency.  Next I have a circuit model having associated fitting parameters (inductances, capacitances, and resistances) which I can use to construct a predicted impedance Zp at these same frequencies.  The fit would then be used to determine parameters.  The whole process would be perfectly suited to nonlinear least squares fitting if I could simply use complex y-values for both the measured Zm and the predicted Zp.    I know I could probably get around the problem I am having by using the standard nonlinear fitting routines and making my y-array twice as long with the first half being the real part and the second half being the imaginary part--and then adjusting my fitting function likewise, but it is so much prettier to simply allow complex y-values in the fitting routines.  (Note to the NI software engineers: make fitting routines that are polymorphic with complex y-variables.)  So I went to editing the Levenberg-Marquardt and ABX.vi to accept complex variables and compute the chi-square as (Zm-Zp)(Zm-Zp)* and both vis were giving me a lot of trouble accepting the modifications.  ABX would not allow editing (even though the protection properties say they are not protected) and I also had various other problems such as replacing the ABX in the Lev-Mar vi as well and saving the modified vis.  Is there something I am missing about modifying these Pro-package vis?
0 Kudos
Message 1 of 2
(2,322 Views)

You should first copy all relevant VIs out of the Vi.lib folder hierarchy and into your own area before you start editing. (Copy using windows explorer).

 

Depending on your LabVIEW version, there are some misguided hurdles in place if you edit a stock NI VI in its original place. For example you can easily save the modifed VI and overwite (and possibly mutilate) the regular tools, breaking all other code that uses fitting (requiring a reinstall! :(), but it won't allow you to save the modified VI under a new name. 

 

Good luck. Personally, I would probably use the regular tools (see below). What is your LabVIEW version?

 


deserio@florida wrote: 
I know I could probably get around the problem I am having by using the standard nonlinear fitting routines and making my y-array twice as long with the first half being the real part and the second half being the imaginary part--and then adjusting my fitting function likewise, but it is so much prettier to simply allow complex y-values in the fitting routines.

Another option would be to simply typecast your complex array to DBL (making it twice as long) and then typecast it back to complex inside the model VI.

Message Edited by altenbach on 02-04-2009 09:26 AM
0 Kudos
Message 2 of 2
(2,319 Views)