Encountering error with using fmincon

11 views (last 30 days)
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) where the Filled_stretchextensometer represents the corresponding stretch data.
clear all
close all
clc
data = xlsread('C:\Users\me-admin\Videos\Daniela\Fresh_5\Fresh5_data.xlsx');
strain_extensometer= data((3:268),3);
time_DIC= data((3:268),2);
experimentalstress_original= data((3:667),7);
time_utm= data((3:667),4);
[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");
figure;
J = @(x,Filled_stretchextensometer) ((x(1).*x(2)*(Filled_stretchextensometer-(1./Filled_stretchextensometer.^2)))./(x(2)-(Filled_stretchextensometer.^2+(2./Filled_stretchextensometer)-3)));
residue_function = @(x) sum((((x(1).*x(2)*(Filled_stretchextensometer-(1./Filled_stretchextensometer.^2)))./(x(2)-(Filled_stretchextensometer.^2+(2./Filled_stretchextensometer)-3))) - predicted_experimentalstress).^2);
x0 = [33, 0.2];
gs = GlobalSearch;
problem = createOptimProblem('fmincon', 'x0', x0,'objective', residue_function);
x = 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 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)');
I am attempting to use the fmincon function in the follwing script with an additional constraint that parameter x(2) > 0, but I am encountering an error. How may I resolve this? I am unable to include the constraint within the optimization.

Accepted Answer

Walter Roberson
Walter Roberson on 7 Sep 2023
Edited: Walter Roberson on 7 Sep 2023
format long g
data = xlsread('Fresh5_Data.xlsx');
strain_extensometer= data((3:268),3);
time_DIC= data((3:268),2);
experimentalstress_original= data((3:667),7);
time_utm= data((3:667),4);
[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");
figure;
J = @(x,Filled_stretchextensometer) ((x(1).*x(2)*(Filled_stretchextensometer-(1./Filled_stretchextensometer.^2)))./(x(2)-(Filled_stretchextensometer.^2+(2./Filled_stretchextensometer)-3)));
residue_function = @(x) sum((((x(1).*x(2)*(Filled_stretchextensometer-(1./Filled_stretchextensometer.^2)))./(x(2)-(Filled_stretchextensometer.^2+(2./Filled_stretchextensometer)-3))) - predicted_experimentalstress).^2);
x0 = [33, 0.2];
gs = GlobalSearch;
problem = createOptimProblem('fmincon', 'x0', x0, 'objective', residue_function, 'lb', [-inf 0]);
[x, resnorm] = run(gs,problem)
GlobalSearch stopped because it analyzed all the trial points. All 31 local solver runs converged with a positive local solver exit flag.
x = 1×2
1.0e+00 * 14.498823559377 4887531.72800873
resnorm =
89.4326352064699
lb = [];
ub = [];
fprintf(['The value of x(1) %f.\n'],x(1));
The value of x(1) 14.498824.
fprintf([ 'The value of x(2) %f.\n'],x(2));
The value of x(2) 4887531.728009.
fprintf(['The value of resnorm %f.\n'], resnorm);
The value of resnorm 89.432635.
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)');

More Answers (0)

Categories

Find more on Stress and Strain in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!