Filter löschen
Filter löschen

how to obtain coefficients and other data from a curve fit object, of the interpolant type, using linear method?

34 Ansichten (letzte 30 Tage)
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 Kommentare
Fabrice Belveze
Fabrice Belveze am 26 Jul. 2024 um 13:42
Hello, I did this fit in the perspective of a harware implementation, therefore I have to precisely know how it works.
I did use the functions you sent me the link to, unfortunately, they return information that I can't use. For instance, "coeffvalues" returns:
ans =
TriangleSurfaceInterpolant with properties:
Type: 'Linear'
which does not give any numerical value, nor any insight on how the fitted object works.
More precisely, I'm not interested in the method which obtains the fit. I'm interested in how the fitted object performs surface approximation.
dpb
dpb vor etwa 20 Stunden
Bearbeitet: dpb vor etwa 4 Stunden
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
ans = 5x2
1.0e+00 * 1790.00 3.90 1800.00 5.30 1810.00 7.20 1820.00 9.60 1830.00 12.90
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
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
coeffs = 1x3
1.0e+00 * 6.5411e-03 -2.3510e+01 2.1130e+04
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
phat=c(cdate(1:5)) % evaluate the fit over same first few points
phat = 5x1
5.5830e+00 5.3121e+00 6.3495e+00 8.6951e+00 1.2349e+01
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by