Objective function is returning Inf or NaN values at initial point. lsqcurvefit cannot continue.
42 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Amir Mirmoini
el 15 de Mzo. de 2023
Comentada: Matt J
el 15 de Mzo. de 2023
Hello together,
I have a diffusion model for porous solids but I get the error message " Objective function is returning Inf or NaN values at initial point. lsqcurvefit cannot continue.". However, I dont understand it since I can calculate the values and wont get Nan or Inf values if I use a normal calculator. Is my code wrong or is it because of numerical problems? Thanks in advance
A = 0.0019634954;
R = 8.314;
T = 298.15;
N_A = 6.02214086*(10^23);
p = 100000;
k_B = 1.38064852E-23;
M = 31.999E-3;
dc = 40;
s_Kunststoff = 23E-06;
p_1 = [1; 0.1343; 0.0173; 0; 0; 0];
p_2 = [0; 0.5089; 0.4445; 0.4606; 0.3222; 0.632];
p_3 = [0; 0.0465; 0.069; 0.061; 0.067; 0.076];
p_4 = [0; 0.2407; 0.3855; 0.3641; 0.4883; 0.7211];
r_m = 15E-09;
d = 0.06E-09;
D_Knudsen = ((2/3)*r_m*((8*R*T)/(pi*M))^0.5);
D_Molekularsieb = D_Knudsen/15
x = [0 5E-09 9E-09 14E-09 18E-09 25E-09]';
y = [33.20312499864E-09 19.57947530784E-09 4.079861110944E-09 1.59143518512E-09 1.456404320928E-09 1.18152006168E-09]';
modelFun = @(b,x) A.*dc./((1./(((D_Knudsen.*p_2)./(b(5).*x))+((D_Molekularsieb.*p_3)./(b(6).*x))+((b(3).*exp(-b(4)./(R.*T)))./x)))+(s_Kunststoff./(b(1).*exp(-b(2)./(R.*T)))));
b0 = [1e+03 8e+04 1e+03 8e+04 1 1]
lb = [0 0 0 0 1 1];
ub = [1e+20 1e+20 1e+20 1e+20 30 30];
b = lsqcurvefit(modelFun,b0,x,y,lb,ub);
times = linspace(x(1),x(end));
plot(x,y,'ko',times,modelFun(b,times),'b-')
legend('Data','Fitted exponential')
title('Data and Fitted Curve')
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!