Curve fitting for 4 independent variables
3 views (last 30 days)
Show older comments
I have the following experimental data (attached xlsx file). I am trying to fit the experimental stress data, which are denoted by predicted_experimentalstress, to the analytical equivalent (Gent model) with four independent variables to be evaluated based on the experimental stretch data. However, the following code using Fmincon doesn't work for more than two variables. Could you please suggest me a way to modify the code to evaluate the four variables from the curve fitting?
data = xlsread('Roundtissuedata.xlsx');
strain_extensometer= data((2:454),2);
time_DIC= data((2:454),1);
experimentalstress_original= data((2:755),9);
time_utm= data((2:755),6);
[F,TF] = fillmissing(strain_extensometer,'linear','SamplePoints',time_DIC);
Filled_stretchextensometer= F+1;
hold on
predicted_experimentalstress= interp1(time_utm,experimentalstress_original,time_DIC,"linear","extrap");
J = @(x,Filled_stretchextensometer) exp((((-x(1)./2).*(x(2)).*(log(x(2)-(Filled_stretchextensometer.^2+(2./Filled_stretchextensometer)-3))./x(2))).^x(3)).*((x(4)).^(-x(3)))).*((x(1).*x(2)*(Filled_stretchextensometer-(1./Filled_stretchextensometer.^2))).*(x(2)./(x(2)-(Filled_stretchextensometer.^2+(2./Filled_stretchextensometer)-3))));
residue_function = @(x) sum(((exp((((-x(1)./2).*(x(2)).*(log(x(2)-(Filled_stretchextensometer.^2+(2./Filled_stretchextensometer)-3))./x(2))).^x(3)).*(x(4)).^(-x(3))).*((x(1).*x(2)*(Filled_stretchextensometer-(1./Filled_stretchextensometer.^2))).*(x(2)./(x(2)-(Filled_stretchextensometer.^2+(2./Filled_stretchextensometer)-3)))) - predicted_experimentalstress).^2));
x0 = [49,2,10,12];
gs = GlobalSearch;
problem = createOptimProblem('fmincon', 'x0', x0, 'objective', residue_function, 'lb', [-inf 0]);
[x, resnorm] = run(gs,problem)
lb = [];
ub = [];
fprintf(['The value of x(1)%f.\n'],x(1));
fprintf([ 'The value of x(2)%f.\n'],x(2));
fprintf([ 'The value of x(3)%f.\n'],x(3));
fprintf([ 'The value of x(4)%f.\n'],x(4));
fprintf(['The value of resnorm %f.\n'], resnorm);
times = linspace(Filled_stretchextensometer(3),Filled_stretchextensometer(end));
plot(Filled_stretchextensometer, predicted_experimentalstress, times, J(x, times), 'r-');
legend('Experiment', 'Fitted curve(Gent Model)');
title('Fresh 5');
xlabel('Stretch');
ylabel('Engineering Stress (KPa)');
0 Comments
See Also
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!