MATLAB: Fit function breaches the lower option limits

Curve Fitting Toolboxfit lowerMATLAB

I was trying to do fit with a script generated from cftool. It puts lower limit of 0 on all coefficients and the result returned is still negative. I would like to share the dataset but I am new to this forum and I don't find any option of sharing file. Please help me.

Best Answer

0 votes Edit Delete Amol answered less than a minute ago
ok here is the script
function [cf_,gof]=myfit(tau,avar,weight)
%MYFIT Create plot of datasets and fits
% MYFIT(TAU,AVAR,WEIGHT)
% Creates a plot, similar to the plot in the main curve fitting
% window, using the data that you provide as input. You can
% apply this function to the same data you used with cftool
% or with different data. You may want to edit the function to
% customize the code and this help message.
%

% Number of datasets: 1
% Number of fits: 1
% Data from dataset "avar vs. tau with weight":
% X = tau:
% Y = avar:
% Weights = weight:
%
% This function was automatically generated on 04-Nov-2009 17:20:51
% --- Create fit "fit 1"
fo_ = fitoptions('method','LinearLeastSquares','Lower',[0 0 0 0 0]);
ok_ = isfinite(tau) & isfinite(avar) & isfinite(weight);
set(fo_,'Weight',weight(ok_));
if ~all( ok_ )
warning( 'GenerateMFile:IgnoringNansAndInfs', ...
'Ignoring NaNs and Infs in data' );
end
ft_ = fittype({'1/(x^2)', '1/x', 'x', 'x^2', '1'},...
'dependent',{'y'},'independent',{'x'},...
'coefficients',{'a', 'b', 'd', 'e', 'c'});
% Fit this model using new data
[cf_,gof] = fit(tau(ok_),avar(ok_),ft_,fo_);
% Or use coefficients from the original fit:
%if 0
% cv_ = { 2.8012463154944958529e-09, 4.1224210467149593554e-06, -6.2806159338057854499e-10, 1.1525415994665557154e-11, 5.4419882197796621562e-07};
% cf_ = cfit(ft_,cv_{:});
end
and yes I am sorry for a late response. I seems that i need to turn on some option to get email notification from the forum