Effacer les filtres
Effacer les filtres

Error using lsqncommon Lower and upper bounds not supported with complex-valued initial function or Jacobian evaluation.

28 vues (au cours des 30 derniers jours)
Hi All
I'm attempting to use lsqcurvefit and as the subject suggests I'm using a complex-valued initial function. After troubleshooting, I understand why this is occuring but I need to work with these complex values. I've looked over MATLAB's site regarding the use of nonlinear solvers to handle complex data (Complex Numbers in Optimization Toolbox Solvers - MATLAB & Simulink (mathworks.com)). I've attempted the suggestions here but other issues occur as a result. I'm exploring alternative options that can handle complex values. Does anyone know of other methods/techniques/solvers that I could use to solve my problem?
Below is sample complex data I'm working with:
-1.82875685467236e-05 - 5.57673335889352e-05i
3.19797913453464e-05 - 8.38049994895477e-05i
8.84510068394548e-05 - 9.49369357476830e-05i
3.40982361372879e-05 + 5.99511245193968e-05i
0.000113645107797032 + 0.000144668977309694i
0.000381430157418632 + 0.000355606573840422i
0.00139432619208296 + 0.000913022966273320i
0.00643682783318257 + 0.00260766847239058i
As a note, I've tried splitting my complex data into real and imaginary but the final results are quite off. Furthermore, I've tried taking the log of these values and this works but for only 1 situation (the last 5 complex data where the imag/real values aren't negative and thus not creating a complex number again when taking the log). I've also tried taking the magnitude and phase of each complex measurement, transforming the data so that they are on the same scale, and some of the results don't align with the physics.

Réponse acceptée

Torsten le 10 Avr 2024
Modifié(e) : Torsten le 10 Avr 2024
If you use "fmincon" and (f(x,xdata)-ydata)' * (f(x,xdata)-ydata) as objective function, complex numbers don't matter because the result is real.
  4 commentaires
Torsten le 10 Avr 2024
Modifié(e) : Torsten le 11 Avr 2024
I just read in the title that you want to define bounds on the parameters. This is only possible if you split the parameters into real and imaginary parts and optimize with the number of parameters doubled.
If you don't need to define bounds on the paramters:
For the numerical solution method of lsqnonlin or lsqcurvefit, it is essential that the residuals are defined for each equation separately, not in a sum of squared differences. Thus
fun = @(x, xdata) (f(x)-ydata)' * (f(x)-ydata)
is not possible for these solvers.
Nicholas Ross
Nicholas Ross le 11 Avr 2024
Ah I see. Setting bounds for this is ideal as there is a certain range the output needs to be within. I can split the data into real and imaginary. When I do that my values are on the scale of 1E-5 to 1E-4, and my output is pretty much ends up being the initial guess or worse. But if I do the same real and imaginary split but take the log each, then my outputs are excellent. Can you help me understand why the same data but with a log transformation is that much better?
As mentioned in my post, this log transformation only works for one subset of my measurements/simulated data.

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Systems of Nonlinear Equations dans Help Center et File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by