how to obtain coefficients and other data from a curve fit object, of the interpolant type, using linear method?
34 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
From a set of data, I could easily obtain a curve fit using curveFitter. The fit is of the interpolant type, using linear method. From what I understand, the underlying method is linear triangular interpolation. But then, I'm unable to get the internal data of the model. I mean, there should be triangle boundaries, coefficients and other constants describing the triangular pieces of surface that approximate my data set, but I was unable to read them from the obtained fit.
So, for this particular fit (linear interpolant), how to get the inside data?
3 comentarios
dpb
hace alrededor de 20 horas
Editada: dpb
hace alrededor de 4 horas
If use the fitted object as it is documented to be used, it most certainly does return values--
load census % get some data to use
format bank % make it print in %f form for legibility
[cdate(1:5) pop(1:5)] % look at first few elements
f=fittype('poly2'); % define a quadratic model
c=fit(cdate,pop,f); % perform the fit
format shorte, format compact % coefficients vary a lot in magnitude so we can see them all
coeffs=coeffvalues(c) % retrieve the coefficients
phat=c(cdate(1:5)) % evaluate the fit over same first few points
plot(cdate,pop) % all the data
hold on
plot(cdate(1:5),phat,'r-') % add the fitted
figure
plot(c) % you get the whole thing automagically if just use the object
In short, read the full documentation and look at the example usage before claiming something doesn't work.
However, for use on an embedded system or the like, you'll undoubtedly be far better served to not use such high level MATLAB features; particularly if all you're after is linear interpolation. You can code that in very few lines much more efficiently. In addition, I suspect a fair amount of this may not be available for the environment you're looking at.
Respuestas (0)
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression 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!