0

Fitting a complex function to complex data

I am calculating an impedance of an electrical circuit. The function is of course complex and so is the measurement data. I'm looking for a way to fit the parameters of the function (capacity, inductivity,...) despite the function being complex.

So far I've often gotten errors about only accepting real matrices and I'm not sure which function would work.

It is unfortunately not an option to separate the impedance function into real and imaginary part as this circuit is fairly complicated and will be altered to even more complicated models.

I'm looking for something like this (in its most basic form):

freq = [1e4, ...]; //measured frequency data Imp = [1+%i*2, ...]; //measured impedance data function Z = mymodel(w, C0, Z0, N) Z = ... endfunction guess = [C0guess, Z0guess, Nguess] //imagine values here [params, errors] = fit_function(x=freq, y=Imp, func=mymodel, start=guess) //a function that fits my parameters so that the result gives the closest function to the data

Scilab