02-12-2013 07:17 AM
Hi,
I am currently facing some issue on Non Linear curve fitting (made some comments on http://forums.ni.com/t5/LabVIEW/Non-linear-curve-fitting-for-complex-data/m-p/2311914, then realised that was from three years ago...).
I am doing curve fitting of impedance data.
I use a combination of different code written previously on the other topic, in order to do data fitting of impedance
(circuit described in Complex_Function.vi). I think that's properly implemented (checked it on a few values, that's fine).
Initial values
C1 =4.7 uF
R1 = 20 Ohms
R2 = 220 Ohms
Yet, I keep having the same error being " error 20068 occrued at NI_Gmath.lvib.LM get new coefficients.vi:1.
Which I do not understand.
Let me know if you have some clues to solve this mistake. I attached the code in the llb and the excel file I am using.
thanks
Kentmey
02-12-2013 10:57 AM
First things first: Your model is wrong by inspection. Your imaginary data is always positive, your model function will produce negative imaginary components for positive parameter values.
Next: You can not feed complex data to the nonlinear fit VI. You must combine the real and imaginary parts into a single array. You can type cast the complex array into a double array, you can interleave the real and imaginary arrays, or you can simply append one to the other. Your model function VI has to combine them in a similar fashion. It does not matter that the X and Y arrays are different lengths (fortunately there is no check so this trick works).
After the fit, simply reverse the process you used to combine the real and imaginary parts to separate them again.
Finally, why do you have a constant 1 wired to the For Loop of your Fit model VI? Remove this and let it autoindex. I assume this was for debugging.
02-12-2013 11:40 AM
Hi,
I made the changes (the data has a -1* in processing, so I changed the sign of the imaginary in the model). Thanks for the other mistakes as well. By curiosity, why can't I send the complex number into the fitting, if the function is complex too?
I am still getting the same issue with that error I mentioned earlier even with that fix though.
02-12-2013 11:53 AM - edited 02-12-2013 12:17 PM
Works fine for me, only had to add some initial values to your VI. By the way, you only display two plots, data and fit, both as imaginary versus real, so I also had to autoscale X to see it. Anyway, no errors for me.
02-12-2013 12:02 PM
I am still getting that error actually... strange.
02-12-2013 12:14 PM
are we using the same version of Labview?
02-12-2013 12:26 PM
I do not have LV11 to test. Works in LV10 and LV12.
Are you loading the data properly. Forgot to mention that I save your data as a CSV file so I had to change the delimiter to a comma in Read from Spreadsheet file.
02-12-2013 12:56 PM
Tried with 2012 as well, it does not work either.
Can you send me back my code with your modifications, maybe I missed some tiny thing in there? That's still quite odd (and I keep having the same error -20068)
Kentmey.
02-12-2013 01:14 PM
Here is the LV10 version with a few more simplifications (cut out the file reading and replaced with default values). Replaced the VI path with a static reference.
02-13-2013 03:29 AM
That definitely works, thanks.
However, I don't really understand how you load the data from the excel file in this program (apologies for my lack of knowledge of LabVIEW...). And when I try to read from the excel file, it does not work...