Encountering error with using fmincon

11 Ansichten (letzte 30 Tage)
Yogesh
Yogesh am 7 Sep. 2023
Bearbeitet: Walter Roberson am 7 Sep. 2023
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Sep. 2023
Bearbeitet: Walter Roberson am 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)');

Weitere Antworten (0)

Kategorien

Mehr zu Stress and Strain finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by