fminsearch for complex input for curve fitting
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear all, I would like to fit experimental data with custom equations. I aim for the best fit of the theoretical curve to the experimental data by minimizing the residuals and use fminsearch to find minimal error.
The attached code works well for the real inputs
[R, fval] = fminsearch(err, 2.11)% finds the minimum of err But it fails for the
[R, fval] = fminsearch(err, 2.0-0.064i)
Help for fminsearch suggests to input split into real, imaginary parts and work to obtain the best fit. I have a little idea of doing this.
Could somebody help me with this problem? Thanks all.
Antworten (2)
Matt J
am 23 Okt. 2014
Bearbeitet: Matt J
am 23 Okt. 2014
Assuming your err function is real-valued,
[R, fval] = fminsearch(@(x) err( complex( x(1),x(2) ) ), [2.0,0.064])
4 Kommentare
Matt J
am 28 Okt. 2014
The objective function must be a mapping from reals to reals. The initial guess x0 must also be real. So, complex(2.11,-0.064) is not legal as an initial point.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!