ALGLIB does not support complex fitting directly, but you may implement it indirectly using ALGLIB optimizers. Complex value, after all, is just a pair of real values (x,y), so you may replace N-dimensional complex problem by equivalent 2N-dimensional real valued one.
Mathematics of the target function shows similar two-fold increase in size. During fitting you multiply complex residuals by their conjugates, so in original formulation you have a term like residual_i*conj(residual_i). In the real-valued formulation, you have equivalent residual_i_x*residual_i_x + residual_i_y*residual_i_y. So, in original formulation you had M squared summands, now you have 2M squared summands.
I recommend you to use minlm subpackage, because it is flexible enough for the task you want to solve. lsfit is explicitly tied to real valued fitting and can not be used for tasks like this.
|