how to get the coeffients out of a sfit object after creating it on some data using 'cubicinterp'.
조회 수: 5 (최근 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!