how to get the coeffients out of a sfit object after creating it on some data using 'cubicinterp'.

6 visualizzazioni (ultimi 30 giorni)
Hi, i want to fit some 3d data, and generate a mathematical description of the surface using the curve fitting toolbox. I used "cubicinterp" as the interpolation method and get the following output:
>> test = fit([X_cart,Y_cart],Z_cart,'cubicinterp','Exclude', nanz) Warning: Duplicate x-y data points detected: using average of the z values. > In curvefit.attention.Warning/throw (line 30) In curvefit.model.SurfaceInterpolantFactory/doCoalesceDuplicatePoints (line 206) In curvefit.model.SurfaceInterpolantFactory/create (line 74) In fit>iSurfaceInterpolation (line 895) In fit>iFit (line 489) In fit (line 108)
Piecewise cubic interpolant:
test(x,y) = piecewise cubic surface computed from p
Coefficients:
p = coefficient structure
I have no idea how to extract the coefficients or any kind of mathematical description out of the sfit object "test" which is generated.
Any ideas?
Thanks for any help.
Simon

Risposte (2)

Mukul Rao
Mukul Rao il 21 Lug 2017
Hi,
Here is an example that demonstrates how to extract fit coefficients from the "sfit" object:

haochen he
haochen he il 30 Nov 2018
I think we do not have access to the model parameters:
[fitresult, gof] = fit( [xData, yData], zData, 'cubicinterp', 'Normalize', 'on' );
names = coeffnames(fitresult); % result is: names = {'p'}
% if you try other properties like 'fitresult.others', an error will goes like:
% For the current fit, you can access these properties: p
% then we try this:
names = coeffnames(fitresult.p);
% result will be an error, if we see the fitresult.p, we can only find the property is Type='Cubic'
  2 Commenti
Antonio Machado Jorge
Antonio Machado Jorge il 17 Ott 2023
It doesn't work for me... I'm on 2023b
>> fitresult.p
ans =
GriddataInterpolant with properties:
Type: 'Cubic'
>> names = fitresult.p.coefs
Unrecognized method, property, or field
'coefs' for class
'curvefit.model.GriddataInterpolant'.
Error in indexing (line 26)
out = subsref(out, subs);

Accedi per commentare.

Categorie

Scopri di più su Visualization and Data Export in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by