Encountering error with using fmincon
11 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
Walter Roberson
2023 年 9 月 7 日
編集済み: Walter Roberson
2023 年 9 月 7 日
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)
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)');
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Stress and Strain についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

