how to get the coeffients out of a sfit object after creating it on some data using 'cubicinterp'.
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
Mukul Rao
2017-7-21
Hi,
Here is an example that demonstrates how to extract fit coefficients from the "sfit" object:
haochen he
2018-11-30
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 个评论
Antonio Machado Jorge
2023-10-17
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);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Visualization and Data Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!