using lsqnonlin with multiple functions
6 次查看(过去 30 天)
显示 更早的评论
im trying to optimize parameters,x, using 3 functions, fun1, fun2, fun3.
the optimized parameters must be the best fit for all 3 functions, not individually.
% ogden
clc
clear all
D=readmatrix('Treloar_data.xlsx');
stretch=D(1:end,1); %this is lambda
lambda=stretch;
stress=D(1:end,2); %this is stress
T_0=stress;
lambda_EBT=D(1:17,5);
T_0_EBT=D(1:17,6);
lambda_shear=D(1:14,3);
T_0_shear=D(1:14,4);
fun1=@(x)((x(1)*(lambda.^(x(4)-1) -lambda.^(-.5*x(4)-1))+x(2)*(lambda.^(x(5)-1) -lambda.^(-.5*x(5)-1))+x(3)*(lambda.^(x(6)-1) -lambda.^(-.5*x(6)-1)))-T_0);
fun2=@(x)((x(1)*(lambda_EBT.^(x(4)-1) -lambda_EBT.^((-7/2)*x(4)-(5/2)))+x(2)*(lambda_EBT.^(x(5)-1) -lambda_EBT.^((-7/2)*x(5)-(5/2)))+x(3)*(lambda_EBT.^(x(6)-1) -lambda_EBT.^((-7/2)*x(6)-(5/2))))-T_0_EBT);
fun3=@(x)((x(1)*(lambda_shear.^(x(4)-1) -lambda_shear.^((-5/2)*x(4)-(3/2)))+x(2)*(lambda_shear.^(x(5)-1) -lambda_shear.^((-5/2)*x(5)-(3/2)))+x(3)*(lambda_shear.^(x(6)-1) -lambda_shear.^((-5/2)*x(6)-(3/2))))-T_0_shear);
fun=[fun1; fun2; fun3]
% x0=[1, 1, 1, 1, 1, 1];%initial geuss is sensitive
x0=[.5649 ,(3.856*10^(-3)) 0 ,1.297, 4.342, 15.13];
x=lsqnonlin(fun,x0);
c(1)=x(1) %mu1
c(2)=x(2) %mu2
c(3)=x(3) %mu3
c(4)=x(4) %alpha1
c(5)=x(5) %alpha2
c(6)=x(6) %alpha3
T_0_ogden=(c(1)*(lambda.^(c(4)-1) -lambda.^(-.5*c(4)-1))+c(2)*(lambda.^(c(5)-1) -lambda.^(-.5*c(5)-1))+c(3)*(lambda.^(c(6)-1) -lambda.^(-.5*c(6)-1)));
T_0_ogden_EBT=(x(1)*(lambda_EBT.^(x(4)-1) -lambda_EBT.^((-7/2)*x(4)-(5/2)))+x(2)*(lambda_EBT.^(x(5)-1) -lambda_EBT.^((-7/2)*x(5)-(5/2)))+x(3)*(lambda_EBT.^(x(6)-1) -lambda_EBT.^((-7/2)*x(6)-(5/2))));
T_0_ogden_shear=(x(1)*(lambda_shear.^(x(4)-1) -lambda_shear.^((-5/2)*x(4)-(3/2)))+x(2)*(lambda_shear.^(x(5)-1) -lambda_shear.^((-5/2)*x(5)-(3/2)))+x(3)*(lambda_shear.^(x(6)-1) -lambda_shear.^((-5/2)*x(6)-(3/2))));
figure
plot(lambda,T_0,'r')
hold on
plot(lambda,T_0_ogden,'b')
plot(lambda_EBT,T_0_ogden_EBT,'g')
plot(lambda_shear,T_0_ogden_shear,'c')
0 个评论
回答(2 个)
Torsten
2023-4-26
移动:Torsten
2023-4-26
So you want
sum(((x(1)*(lambda.^(x(4)-1) -lambda.^(-.5*x(4)-1))+x(2)*(lambda.^(x(5)-1) -lambda.^(-.5*x(5)-1))+x(3)*(lambda.^(x(6)-1) -lambda.^(-.5*x(6)-1)))-T_0).^2) +
sum((((x(1)*(lambda_EBT.^(x(4)-1) -lambda_EBT.^((-7/2)*x(4)-(5/2)))+x(2)*(lambda_EBT.^(x(5)-1) -lambda_EBT.^((-7/2)*x(5)-(5/2)))+x(3)*(lambda_EBT.^(x(6)-1) -lambda_EBT.^((-7/2)*x(6)-(5/2))))-T_0_EBT).^2) +
sum(((x(1)*(lambda_shear.^(x(4)-1) -lambda_shear.^((-5/2)*x(4)-(3/2)))+x(2)*(lambda_shear.^(x(5)-1) -lambda_shear.^((-5/2)*x(5)-(3/2)))+x(3)*(lambda_shear.^(x(6)-1) -lambda_shear.^((-5/2)*x(6)-(3/2))))-T_0_shear).^2)
to be minimzed with respect to x ?
Then define
fun = @(x)[fun1(x);fun2(x);fun3(x)];
Alex Sha
2023-8-4
@joshua payne refer to the results below
Sum Squared Error (SSE): 0.377485784540046
Root of Mean Square Error (RMSE): 0.0821024821858161
Correlation Coef. (R): 0.996098098188982
R-Square: 0.992211421215707
Parameter Best Estimate
--------- -------------
c1 0.0323483986102822
c2 -1.23856186333989
c3 1.19422161081346E-14
c4 3.36896942510881
c5 -0.571016034599837
c6 17.1390641835716
T_0_ogde:
T_0_ogden
T_0_ogden_shear
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!