Borrar filtros
Borrar filtros

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

6 visualizaciones (últimos 30 días)
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

Respuestas (2)

Mukul Rao
Mukul Rao el 21 de Jul. de 2017
Hi,
Here is an example that demonstrates how to extract fit coefficients from the "sfit" object:

haochen he
haochen he el 30 de Nov. de 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 comentarios
Antonio Machado Jorge
Antonio Machado Jorge el 17 de Oct. de 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);

Iniciar sesión para comentar.

Categorías

Más información sobre Fit Postprocessing 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!

Translated by