Optimization least square approach

1 次查看(过去 30 天)
Galileo Pini
Galileo Pini 2021-6-12
编辑: Matt J 2021-6-12
Hi everybody
I'm trying to find the optimum value of a vector of parameters to approximate an experimental set of data starting from a simplified vector x_0
x_0= [0.13084 ; 0 ; 0; 0; 0; 0 ]
par=fminsearch(@(par)errHjk(par,frq_redHjk,csi_i,w0i,Hjk_red_exp),x_0,options);
where has been defined the fun :
function err = errHjk(par, frq_redHjk,csi_i,w0i, Hjk_red_exp)
Aj=par(1,1);
Bj=par(2,1);
Cj=par(3,1);
Dj=par(4,1);
Ej=par(5,1);
Fj=par(6,1);
omega_red= frq_redHjk*2*pi;
Hjki=(Aj+1i*Bj)./(-omega_red.^2+2i*w0i*csi_i+w0i^2) + Cj+1i*Dj +(Ej+1i*Fj)./omega_red.^2 ;
%Output the error
error= (Hjki-Hjk_red_exp);
err = sum (real(error.^2)) + sum(imag(error.^2)) ;
end
instead of find the minimum value the error found by the program continues to increase
Do you know what is wrong with this code ?

回答(1 个)

Matt J
Matt J 2021-6-12
编辑:Matt J 2021-6-12
Shouldn't it be
err = sum (real(error).^2) + sum(imag(error).^2) ;
If so, then this is a linear least squares problem, and you should probably just use mldivide() instead of fminsearch.

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by