Minimize the sum of squared errors between the experimental and predicted data in order to calculate two parameters

In my research work, I use a model and I want to minimize the sum of squared errors between the experimental and predicted data in order to calculate two parameters.
The experimental data are:
u exp: [0.709; 0.773 ;0.823 ;0.849 ;0.884 ;0.927 ;0.981 ;1.026 ;1.054 ;1.053 ;1.048;1.039] ;
observed at z=[ 0.006;0.012;0.018;0.024;0.03;0.046;0.069;0.091;0.122;0.137;0.152;0.162];
The equation of the model that I use is:
u model=0.1073*((log(0.13/z)-1/3*(1-(z/0.13)^3)+2*a*(1+(b)^0.5)*cos(11.89*z)); and I want to calculate the parameters “a” et “b” by minimizing the sum of squared errors between “u exp” and “u model”.
Someone here can help me please?
Thank you already for your help!

 채택된 답변

You can use MatLab's fmincon.
z = [0.006;0.012;0.018;0.024;0.03;0.046;0.069;0.091;0.122;0.137;0.152;0.162];
u_exp = [0.709;0.773;0.823;0.849;0.884;0.927;0.981;1.026;1.054;1.053;1.048;1.039];
u_mod = @(P) 0.1073*(log(0.13./z)-1/3*(1-(z/0.13).^3)+2*P(1).*(1+P(2).^0.5).*cos(11.89*z));
sum_sq_err = @(P) sum((u_exp-u_mod(P)).^2);
P = fmincon(sum_sq_err,[0.1,0.1]);
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
a = P(1)
a = 2.0158
b = P(2)
b = 0.3185
hold on
plot(z,u_exp,'o')
plot(z,u_mod(P))
hold off
grid on

댓글 수: 4

If you don't have the optimisation toolbox, you can use fminsearch
z = [0.006;0.012;0.018;0.024;0.03;0.046;0.069;0.091;0.122;0.137;0.152;0.162];
u_exp = [0.709;0.773;0.823;0.849;0.884;0.927;0.981;1.026;1.054;1.053;1.048;1.039];
u_mod = @(P) 0.1073*(log(0.13./z)-1/3*(1-(z/0.13).^3)+2*P(1).*(1+P(2).^0.5).*cos(11.89*z));
sum_sq_err = @(P) sum((u_exp-u_mod(P)).^2);
P = fminsearch(sum_sq_err,[0.1,0.1])
P = 1×2
1.8969 0.4387
hold on
plot(z,u_exp,'o')
plot(z,u_mod(P))
hold off
grid on
Thanks a lot for your help Davide and Mathieu !
I haven't really had optimization toolboxes, but after installing it, the algorithm works fine. Now, I can adapt easily the equations of others functions that I use to continue my work.
Thank you !
z = [0.006;0.012;0.018;0.024;0.03;0.046;0.069;0.091;0.122;0.137;0.152;0.162];
u_exp = [0.345;0.281;0.231;0.205;0.17;0.127;0.073;0.028;0.00;0.0010;0.0060;0.015];
u_mod = @(P) 0.1073*((log(0.132./z)-(1/3)*(1-(z/0.132).^3)+2*P(2).*(1+(P(1)).^0.5).*(cos(pi*z/0.264)).^2));
sum_sq_err = @(P) sum((u_exp-u_mod(P)).^2);
P = fminsearch(sum_sq_err,[0.01,0.01])
hold on
plot(z,u_exp,'o')
plot(z,u_mod(P))
hold off
grid on
P =
0.0506 0.2198
With the god data, everything it's ok.
THANK YOU FOR YOUR HELPS!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

질문:

2023년 3월 28일

댓글:

2023년 3월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by