Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
yahya rezvani
el 12 de Feb. de 2021
Comentada: Walter Roberson
el 12 de Feb. de 2021
Hello . i try to curve fit nonliner equation by lsqcurvefit and get error.
function F = myfunp(a,data)
zdata=[2370.1776112981,26665.5436328856,33999.0700566522,43581.3827551805,56913.3992480947,88844.7226527384,130991.934524133,15112.911231467,176285.501029454,223360.820798491,294455.827929450,35478.787278946,411258.878280649,422702.346106183,511111.835129998,633910.342810244,780340.236378774,619555.134715430,633756.837052416,788803.530398270,777517.401792431,773693.310713579,844333.304097923,150471.6450798029,20517.8541413645,28176.4764184613,29779.9220185300,584153.2552467975,757318.1239141541,984123.5255855076,127002.474102260,157119.325006092,211544.282909359,281369.717982640,271505.093553462,327050.316856829,344420.741097441,374147.438486281,421984.526771006,432866.381682883,554318.948982768,471859.782416242,584014.198110098,622301.344956696]
ydata=[473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000];
xdata=[1.08768000000,4.56728200000,4.99472000000,5.392799100000,6.791900000,8.11234546400000,11.3288295200000,15.2542138200000,23.7895322600000,38.9844910700000,70.9384511000000,100.361732800000,139.249301900000,168.187221200000,275.463489000000,323.697079700000,380.152481600000,511.387441300000,718.018141700000,852.617257800000,927.814899300000,1311.46673800000,1594.53133400000,2.170800000,3.2341306200000,4.161204900000,6.9362766600000,7.13110839100000,12.3316076700000,15.1135745800000,26.7895322600000,37.2653961400000,50.5485060700000,80.8837167700000,89.4791805100000,115.361732800000,129.025620400000,135.094336600000,219.59504900000,258.623830500000,333.908380200000,328.757892400000,444.190385600000,630.380891400000,751.682901300000,871.212537500000,1157.09126200000,1521.09905800000,4.75969298600000,7.91421685000000,10.4898360300000,13.7855398600000,23.1085904900000,30.23414500000,44.5823445700000,67.94350200000,92.278451600000,120.278265300000,122.956453700000,281.618343800000,333.757892400000,419.290040000000,555.402383500000,628.192380300000,831.755300000];
data = [xdata ; ydata];
x=data(1,1);
y=data(2,1);
fun= @(a,data)(1./a(1)).*(((x.*exp(a(2)./(8.314.*y))./a(3)).^(1./a(4)))+sqrt((((x.*exp(a(2)./(8.314.*y))./a(3)).^(2./a(4)))+1)));
a0 = [3; 66666; 2e+10; 2];
lb=[0; 5555; 1e+10 ; 0];
ub=[258; 205588; 1e+15 ; 4];
a = lsqcurvefit(@myfun, a0, data, zdata,lb ,ub)
thank you .
Best regards
0 comentarios
Respuesta aceptada
Walter Roberson
el 12 de Feb. de 2021
Editada: Walter Roberson
el 12 de Feb. de 2021
format long g
zdata=[2370.1776112981,26665.5436328856,33999.0700566522,43581.3827551805,56913.3992480947,88844.7226527384,130991.934524133,15112.911231467,176285.501029454,223360.820798491,294455.827929450,35478.787278946,411258.878280649,422702.346106183,511111.835129998,633910.342810244,780340.236378774,619555.134715430,633756.837052416,788803.530398270,777517.401792431,773693.310713579,844333.304097923,150471.6450798029,20517.8541413645,28176.4764184613,29779.9220185300,584153.2552467975,757318.1239141541,984123.5255855076,127002.474102260,157119.325006092,211544.282909359,281369.717982640,271505.093553462,327050.316856829,344420.741097441,374147.438486281,421984.526771006,432866.381682883,554318.948982768,471859.782416242,584014.198110098,622301.344956696]
ydata=[473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,473.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,483.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000,493.150000000000];
xdata=[1.08768000000,4.56728200000,4.99472000000,5.392799100000,6.791900000,8.11234546400000,11.3288295200000,15.2542138200000,23.7895322600000,38.9844910700000,70.9384511000000,100.361732800000,139.249301900000,168.187221200000,275.463489000000,323.697079700000,380.152481600000,511.387441300000,718.018141700000,852.617257800000,927.814899300000,1311.46673800000,1594.53133400000,2.170800000,3.2341306200000,4.161204900000,6.9362766600000,7.13110839100000,12.3316076700000,15.1135745800000,26.7895322600000,37.2653961400000,50.5485060700000,80.8837167700000,89.4791805100000,115.361732800000,129.025620400000,135.094336600000,219.59504900000,258.623830500000,333.908380200000,328.757892400000,444.190385600000,630.380891400000,751.682901300000,871.212537500000,1157.09126200000,1521.09905800000,4.75969298600000,7.91421685000000,10.4898360300000,13.7855398600000,23.1085904900000,30.23414500000,44.5823445700000,67.94350200000,92.278451600000,120.278265300000,122.956453700000,281.618343800000,333.757892400000,419.290040000000,555.402383500000,628.192380300000,831.755300000];
size(xdata)
size(ydata)
N = min([length(xdata), length(ydata), length(zdata)]);
data = [xdata(1:N); ydata(1:N)].'; %x y must be columns
fun= @(a,data)(1./a(1)).*(((data(:,1).*exp(a(2)./(8.314.*data(:,2)))./a(3)).^(1./a(4)))+sqrt((((data(:,1).*exp(a(2)./(8.314.*data(:,2)))./a(3)).^(2./a(4)))+1)));
a0 = [3; 66666; 2e+10; 2];
lb=[0; 5555; 1e+10 ; 0];
ub=[258; 205588; 1e+15 ; 4];
a = lsqcurvefit(fun, a0, data, reshape(zdata(1:N), [], 1),lb ,ub)
1 comentario
Walter Roberson
el 12 de Feb. de 2021
Your X, Y, and Z are all different lengths.
Your data has to be arranged in columns.
You were asking for function @myfun after naming your anonymous function fun
You were extracting only one x and one y and using those in your fitting, instead of using all of the x and all of the y
You cannot just use your x and y as constants in your fitting: the fitting process passes in some trial data of different size, so you have to use the data passed in.
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!