- Community Home
- :
- Discussion Forums
- :
- Most Active Software Boards
- :
- LabVIEW
- :
- Non-linear curve fitting for complex data

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

11-04-2009 12:54 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Hi,

I want to perform a non-linear curve fitting for complex impedance data obtained at different frequencies. The model impedance equation contains real and imaginary parts and I'm trying to use the Non-linear Curve fit LM Formula string instance of the non-linear curve fit VI. Can someone give me a guide on how to proceed?.

The model equation is as shown below:

Z = R + i((2pi*f)^a)/Y0 - i(Rs)/(C - i/(C*2pi*f)) + i(L*2pi*f)

Where R,Rs,a,Y0,C and L are parameters while f is the frequency.

I just don't know how to handle the complex parts of the equation in the curve fitting VI. Any assistance will be appreciated.

Thanks

11-04-2009 01:15 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

A couple of quick thoughts. First, I would give serious consideration to using a VI instead of the string. You can pass complex data into and out of the fit using this trick, and the VI can perform complex math. I have done this many times to fit complex impedance data.

If you insist on the string VI you could break up the function into real and imaginary parts and fit them separately. Or just fit one component since the impedance is an analytic function the real and imaginary parts are related by Kramers-Kronig relations (finding one fixes the other). You are only fitting half of your data though.

11-04-2009 01:46 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Thanks Darin K,

I will try it and let you how it turned out for me. Thanks again

11-04-2009 05:32 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Hi Darin K,

I tried to write the code and follow the tip you included but I couldn't finish the coding. I've attached the extent of what I was able to do. I needed to start with a 2D array of of complex data but I couldn't use both the type cast and the decimate 1D array functions. For example the decimate 1d array function on the funtion pallet had only one input while the one you attached had two inputs.

Anyways, I wanted to create two arrays, one Real and one Imaginary and make them the x and y inputs while designating the frequency as the independent variable as you can see in the attached unfinished VI. I used the formular instance of the Non-linear curve fit VI so I can input my model equation and define the paramenters.

I'm just stuck at this point and would like some help to fix and finish it. I've attached the vi and my Labview software version is 8.2.

Thanks

11-04-2009 05:37 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Some data to test with would be very useful.

11-04-2009 06:36 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

11-04-2009 07:30 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Please double check your formula, it doesn't make sense from a units standpoint.

11-04-2009 10:02 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

11-05-2009 06:00 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Hi Darin K,

I didn't quite understand your code but here is the impedance function again separated clearely into real and imaginary parts. Can you make the change and them explain the code and how you made the change. Thanks again for the help.

Real part=

**R + Rs/(1 + 39.4784176043574*(0.000000001*C)^2*f^2*Rs^2) + COS(1.57079632679489*a)/(6.28318530717958^a*f^a*0.000001*Y0)**

Imaginary part =

**6.28318530717958*f*(0.000000001*L - (0.000000001*C*Rs^2)/(1 + 39.4784176043574*(0.000000001*C)^2*f^2*Rs^2)) - SIN(1.57079632679489*a)/(6.28318530717958^a*f^a*0.000001*Y0)**

11-05-2009 01:19 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report to a Moderator

Your function never did make much sense to me, so I just assumed it was a series RLC with a separate R in parallel with C and some frequency dependent reactance.

ComplexFitExample takes a complex array of data, converts it to a DBL array [Re,Im,Re,Im...] passes it to the fit function along with a reference to the VI which calculates f(x,a) [ComplexFunction.vi]. Complex Function.vi calculates Z for each value of x (frequency) and generates an array of the form [Re,Im,Re,Im] to match the form of the data. All math is done using complex numbers, no need to deal with real and imaginary components. After the fit, the data is type cast back to an array of complex numbers, and plotted on an XY graph.

When you sort out the function (keep it complex), just change the code inside the for loop of ComplexFunction.vi, that's all.