Curve fitting toolbox error "NaN computed by model function, fitting cannot continue"
Afficher commentaires plus anciens
Hello,
I have a set of experimental data on which i am trying to fit 5 analytical functions (Hyperelastic models) using Levenberg-Marquardt algorithm. The models are as follows:
1) Neo-Hookean: y=2*c1*(x^2-1/x)
2) Yeoh: y=2*(x^2-1/x)*(c1+2*c2*(x^2+2/x-3)+3*c3*(x^2+2/x-3)^2)
3) Mooney-Rivlin: y=2*(x^2-1/x)*(c1+c2/x)
4) Ogden-N3: y=c1*(x^c2-2^(-1+c2)*x^(-c2/2))+c3*(x^c4-2^(-1+c4)*x^(-c4/2))+c5*(x^c6-2^(-1+c6)*x^(-c6/2))
5) Humphrey: y=2*(x^2-1/x)*c1*c2*exp(c2*(x^2+2/x-3))
The data file is attached so you can simply use the custom equation, use the above analytical functions, in the curve fitting toolbox.
clc; clear all; close all;
A = readmatrix('Specimen_mean.csv');
Xdata = A(:,1); % stretch [mm/mm]
Ydata = A(:,2); % Stress [Pa]
The 1,2 and 3 fit very well, though 4 and 5 cannot be fit to the data. The 4 gives the error "NaN computed by model function, fitting cannot continue" and the 5 gives the message "Fit computation did not converge". I have no idea how to deal with the mentioned problems. Any help would be highly appreciated.
Sincerely
Masoud
6 commentaires
Alex Sha
le 11 Août 2021
Hi, It is very likely that it is caused by your unreasonable guessing of initial start values for each parameter, refering to the results below:
4) Ogden-N3:
Root of Mean Square Error (RMSE): 1423.18186169142
Sum of Squared Residual: 364580390.060542
Correlation Coef. (R): 0.999946452632523
R-Square: 0.999892908132366
Parameter Best Estimate
---------- -------------
c1 -61049.116009665
c2 3.59112566549972
c3 65238.8770597832
c4 3.56032628280848
c5 48597.4475162964
c6 0.325066948373278

5) Humphrey
Root of Mean Square Error (RMSE): 4036.17249012034
Sum of Squared Residual: 2932323906.60076
Correlation Coef. (R): 0.999573161635061
R-Square: 0.999146505461111
Parameter Best Estimate
---------- -------------
c1 -1519375.72696327
c2 -0.0058933760536844

masoud meskin
le 11 Août 2021
Alex Sha
le 12 Août 2021
Hi, manually guessing of startpoints is always an extreamly hard task, unfortunatly, most of fitting tools (including Matlab) heavely depend on the goodness of guessing.
The results shown above are obtained by one another package other than Matlab, the step for guessing startpoints is no longer required anymore, all are done by package itself.
You may try the global optimization toolbox in Matlab, theorically,the tools with global optimization algorithms are not need to provide start-values.
masoud meskin
le 16 Août 2021
Alan Weiss
le 16 Août 2021
I am not sure why you didn't use the Levenberg-Marquardt algorithm in lsqcurvefit when running MultiStart. That might save a step (no curve fitting toolbox needed).
options = optimoptions('lsqcurvefit','Algorithm','levenberg-marquardt');
problem = createOptimProblem('lsqcurvefit',...
'objective',model,'xdata',xData','ydata',yData','x0',[-1e6 -1e-3],'lb',[-1e7 -1],...
'ub',[1e7 1],'options',options);
Alan Weiss
MATLAB mathematical toolbox documentation
masoud meskin
le 16 Août 2021
Réponses (0)
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!