LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Imaginary unit in formula string

Hello,

 

I'm trying to do non-linear curve fit using Levenberg-Marquardt algorithm.

 

My formula is R1+1/(1/R2+j*2pi*f*C) so i denoted R1 as a, R2 as b, C as c and f as x. ('j' is imaginary unit)

 

In LV model string i wrote: a+1/(1/b+i*pi(2)*x*c)

 

Unfortunately it doesn't work. LV treats 'i' as another parameter. How to put imaginary unit into the model string?

 

If i'm able to put complex numbers array to nonlinear curve fit VI then it must be method to calculate complex numbers using tis VI.

 

Regards

Kacper

 

qq.jpg

0 Kudos
Message 1 of 3
(3,223 Views)

 


@kacperek wrote:

If i'm able to put complex numbers array to nonlinear curve fit VI then it must be method to calculate complex numbers using tis VI.


 

Don't make assumptions based on flawed observations. 😄

 

The Fitting VIs don't accept complex numbers. If you wire a complex array to "nonlinear curve fit", you get a red coercion dot, meaning that whatever the function uses is no longer complex.

 

However, nothing is impossible. I would recommend to use the "VI model" polymorphic instance. Remember that whatever you do with the data is done entirely in the model VI, so you could for example make a Y array that has the RE and IM parts interlaced (easiest done by typecasting the 1D CDB array to a 1D DBL array).

 

Whatever you do inside the model is up to you, you could easily cast back to complex for the computations. The only requirement: Whatever you compute form the fitting parameters must be compared directly (1:1) with your data array.

 

I the past I have posted many examples for this, I'll do a search...

0 Kudos
Message 2 of 3
(3,209 Views)

ok, thanks!

 

So i did it this way - http://forums.ni.com/t5/LabVIEW/Non-linear-curve-fitting-for-complex-data/m-p/1016568 and it seems to work.

 

But in future i want to build model when application runs, from text code eq. R(CR) means one resistance in series with parallel capacitance and another resistance. I can't build VI models for every possible combination of elements.

0 Kudos
Message 3 of 3
(3,192 Views)