Encountering error with using fmincon
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Yogesh
il 7 Set 2023
Modificato: Walter Roberson
il 7 Set 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.
0 Commenti
Risposta accettata
Walter Roberson
il 7 Set 2023
Modificato: Walter Roberson
il 7 Set 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)
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Stress and Strain in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

