Non-Linear Curve fit: Error using svd
Show older comments
I am conducting a non linear fit with multiple parameters, the data set is pretty big with 622 elements. The code I've used is shown below.
G = 6.67*(10^-11);
H = 73.8;
fun = @(b,X) ((100.*G.*(H^2)).*((b(1).^3)./X).*((log(abs(1+(X./b(2))))-((X./b(2))./((X./b(2))+1)))./(log(abs(1+(b(1)./b(2))))-((b(1)./b(2))./((b(1)./b(2))+1))))) + ((4.*pi.*G).*b(3).*b(4).*((X./(2.*b(4))).^2).*((besseli(0,(X./(2.*b(4)))).*besselk(0,(X./(2.*b(4)))))-(besseli(1,(X./(2.*b(4)))).*besselk(0,(X./(2.*b(4))))))) + (G.*22.665.*(b(5).^2).*b(6));
opts = statset('nlinfit');
%opts.RobustWgtFun = 'bisquare';
b0 = [5000; 3; 340; 90; 300; 600];
mdl = fitnlm(x,y,fun,b0,'Options',opts);
I get the following error:
Error using svd
Input to SVD must not contain NaN or Inf.
Error in internal.stats.isEstimable (line 108)
[V,Sx,U] = svd(X,0);
Error in NonLinearModel/fitter (line 1146)
internal.stats.isEstimable(eye(numel(model.Coefs)),'DesignMatrix',J_out,'TolSVD',TolSVD);
Error in classreg.regr.FitObject/doFit (line 94)
model = fitter(model);
Error in NonLinearModel.fit (line 1446)
model = doFit(model);
Error in fitnlm (line 99)
model = NonLinearModel.fit(X,varargin{:});
Error in Curve_Fit_Take_2 (line 9)
mdl = fitnlm(x,y,fun,b0,'Options',opts);
I believe the error is with some NaNs during processing, how do I go about this as I'm very sure there are no NaN values in my data set. Let me know if you also have a better way to find a non-linear fit.
Thanks in advance !!
Accepted Answer
More Answers (0)
Categories
Find more on Linear Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!