fit function breaches the lower option limits

4 visualizaciones (últimos 30 días)
Amol
Amol el 26 de En. de 2011
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.

Respuesta aceptada

Amol
Amol el 3 de Feb. de 2011
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
  7 comentarios
Walter Roberson
Walter Roberson el 4 de Feb. de 2011
It is unconditionally true that IEEE Double Precision Binary Floating Point numbers have 53 bits of precision, which is a dynamic range of about 1E-16.
If you need greater precision, then you need to either use the Symbolic Toolbox, or the Fixed Point Toolbox, or the Matlab File Exchange contribution for Variable Precision calculations, vpi . Note though that the functions you are wanting to use are probably not defined with any of these kinds of numeric representation.
Amol
Amol el 7 de Feb. de 2011
thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by